I had a problem with the gd and mysqli mods on my PHP5.2/Apache2.2/Windows 2003 server. Even after enabling the options in the php.ini file and restarting the Apache service, the mods still would not load. I even tried to restart the Windows 2003 server that php is loaded on - and no go. After reviewing the system path variables in Windows, I noticed that the c:\php directory was set in the path variable, but not the folder for the gd, mysqli and others mods. So I added c:\php\ext to the path variable and rebooted the server. THAT FIXED IT!!
Windows 下安装扩展库
在 Windows 下安装完 PHP 和 web 服务器之后,可能想要安装一些扩展库来获得更多功能。可以通过修改 php.ini 来选择当 PHP 启动时加载哪些扩展库。也可以在脚本中通过使用 dl() 来动态加载。
PHP 扩展库的 DLL 文件都具有 php_ 前缀。
很多扩展库都内置于 Windows 版的 PHP 之中。这意味着要加载这些扩展库不需要额外的 DLL 文件和 extension 配置指令。Windows 下的 PHP 扩展库列表列出了需要或曾经需要额外 PHP DLL 文件的扩展库。下面是内置的扩展库列表:
PHP 4 中(截止到 PHP 4.3.11):BCMath,Caledar,COM,Ctype,FTP,MySQL,ODBC,Overload,PCRE,Session,Tokenizer,WDDX,XML 和 Zlib。
PHP 5 中(截止到 5.0.4)有以下修改。新增内置:DOM,LibXML,Iconv,SimpleXML,SPL 和SQLite。以下不再内置:MySQL 和 Overload。
PHP 搜索扩展库的默认位置在 PHP 4 中是 C:\php4\extensions,在 PHP 5 中是 C:\php5。要修改此项以符合用户自己的 PHP 设置,需要编辑 php.ini 文件:
-
需要修改 extension_dir 设置以指向用户放置扩展库的目录或者说放置 php_*.dll 文件的位置。例如:
extension_dir = C:\php\extensions
-
要在 php.ini 中启用某扩展库,需要去掉该行 extension=php_*.dll 前的注释符号,将想要加载的扩展库前的分号(;)删除即可。
Example#1 启用 Bzip2 扩展库
// 将这一行 ;extension=php_bz2.dll // 改成这样 extension=php_bz2.dll
-
有些扩展库需要额外的 DLL 才能工作。其中一部分包括在发行包里,PHP 4 中在 C:\php\dlls\ 目录下,PHP 5 中在主目录下,但还有一些,例如 Oracle(php_oci8.dll)所需要的 DLL 没有绑定在发行包里。如果安装 PHP 4,将绑定的 DLL 从 C:\php\dlls 拷贝到主目录 C:\php 中。别忘了将 C:\php 放到系统路径 PATH 中去(此过程在另外的 FAQ 条目中有说明)。
-
某些 DLL 没有绑定在 PHP 发行包中,详情见每个扩展库的文档页。此外有关 PECL 的说明见手册页 PECL 扩展库安装。在 PECL 中有日益增加数目巨大的 PHP 扩展库,这些扩展库需要单独下载。
Note: 如果运行服务器模块版的 PHP,在修改了 php.ini 之后别忘了重新启动 web 服务器以使其改动生效。
下表说明了哪些扩展库需要额外的 DLL。
| 扩展库 | 说明 | 注解 |
|---|---|---|
| php_bz2.dll | bzip2 压缩函数库 | 无 |
| php_calendar.dll | 历法转换函数库 | 自 PHP 4.0.3 起内置 |
| php_cpdf.dll | ClibPDF 函数库 | 无 |
| php_crack.dll | 密码破解函数库 | 无 |
| php_ctype.dll | ctype 家族函数库 | 自 PHP 4.3.0 起内置 |
| php_curl.dll | CURL,客户端 URL 库函数库 | 需要:libeay32.dll,ssleay32.dll(已附带) |
| php_cybercash.dll | 网络现金支付函数库 | PHP <= 4.2.0 |
| php_db.dll | DBM 函数库 | 已废弃。用 DBA 替代之(php_dba.dll) |
| php_dba.dll | DBA:数据库(dbm 风格)抽象层函数库 | 无 |
| php_dbase.dll | dBase 函数库 | 无 |
| php_dbx.dll | dbx 函数库 | |
| php_domxml.dll | DOM XML 函数库 | PHP <= 4.2.0 需要:libxml2.dll(已附带),PHP >= 4.3.0 需要:iconv.dll(已附带) |
| php_dotnet.dll | .NET 函数库 | PHP <= 4.1.1 |
| php_exif.dll | EXIF 函数库 | 需要 php_mbstring.dll。并且在 php.ini 中,php_exif.dll 必须在 php_mbstring.dll之后加载。 |
| php_fbsql.dll | FrontBase 函数库 | PHP <= 4.2.0 |
| php_fdf.dll | FDF:表单数据格式化函数库 | 需要:fdftk.dll(已附带) |
| php_filepro.dll | filePro 函数库 | 只读访问 |
| php_ftp.dll | FTP 函数库 | 自 PHP 4.0.3 起内置 |
| php_gd.dll | GD 库图像函数库 | 在 PHP 4.3.2 中删除。此外注意在 GD1 中不能用真彩色函数,用 php_gd2.dll 替代。 |
| php_gd2.dll | GD 库图像函数库 | GD2 |
| php_gettext.dll | Gettext 函数库 | PHP <= 4.2.0 需要 gnu_gettext.dll(已附带),PHP >= 4.2.3 需要 libintl-1.dll,iconv.dll(已附带)。 |
| php_hyperwave.dll | HyperWave 函数库 | 无 |
| php_iconv.dll | ICONV 字符集转换 | 需要:iconv-1.3.dll(已附带),PHP >=4.2.1 需要 iconv.dll |
| php_ifx.dll | Informix 函数库 | 需要:Informix 库 |
| php_iisfunc.dll | IIS 管理函数库 | 无 |
| php_imap.dll | IMAP,POP3 和 NNTP 函数库 | 无 |
| php_ingres.dll | Ingres II 函数库 | 需要:Ingres II 库 |
| php_interbase.dll | InterBase functions | 需要:gds32.dll(已附带) |
| php_java.dll | Java 函数库 | PHP <= 4.0.6 需要:jvm.dll(已附带) |
| php_ldap.dll | LDAP 函数库 | PHP <= 4.2.0 需要 libsasl.dll(已附带),PHP >= 4.3.0 需要 libeay32.dll,ssleay32.dll(已附带) |
| php_mbstring.dll | 多字节字符串函数库 | 无 |
| php_mcrypt.dll | Mcrypt 加密函数库 | 需要:libmcrypt.dll |
| php_mhash.dll | Mhash 函数库 | PHP >= 4.3.0 需要:libmhash.dll(已附带) |
| php_mime_magic.dll | Mimetype 函数库 | 需要:magic.mime(已附带) |
| php_ming.dll | Ming 函数库(Flash) | 无 |
| php_msql.dll | mSQL 函数库 | 需要:msql.dll(已附带) |
| php_mssql.dll | MSSQL 函数库 | 需要:ntwdblib.dll(已附带) |
| php_mysql.dll | MySQL 函数库 | PHP >= 5.0.0 需要 libmysql.dll(已附带) |
| php_mysqli.dll | MySQLi 函数库 | PHP >= 5.0.0 需要 libmysql.dll(PHP <= 5.0.2 中是 libmysqli.dll)(已附带) |
| php_oci8.dll | Oracle 8 函数库 | 需要:Oracle 8.1+ 客户端库 |
| php_openssl.dll | OpenSSL 函数库 | 需要:libeay32.dll(已附带) |
| php_oracle.dll | Oracle 函数库 | 需要:Oracle 7 客户端库 |
| php_overload.dll | 对象重载函数库 | 自 PHP 4.3.0 起内置 |
| php_pdf.dll | PDF 函数库 | 无 |
| php_pgsql.dll | PostgreSQL 函数库 | 无 |
| php_printer.dll | 打印机函数库 | 无 |
| php_shmop.dll | 共享内存函数库 | 无 |
| php_snmp.dll | SNMP 函数库 | 仅用于 Windows NT! |
| php_soap.dll | SOAP 函数库 | PHP >= 5.0.0 |
| php_sockets.dll | Socket 函数库 | 无 |
| php_sybase_ct.dll | Sybase 函数库 | 需要:Sybase 客户端库 |
| php_tidy.dll | Tidy 函数库 | PHP >= 5.0.0 |
| php_tokenizer.dll | Tokenizer 函数库 | 自 PHP 4.3.0 起内置 |
| php_w32api.dll | W32api 函数库 | 无 |
| php_xmlrpc.dll | XML-RPC 函数库 | PHP >= 4.2.1 需要 iconv.dll(已附带) |
| php_xslt.dll | XSLT 函数库 | PHP <= 4.2.0 需要 sablot.dll,expat.dll(已附带)。PHP >= 4.2.1 需要 sablot.dll,expat.dll,iconv.dll(已附带)。 |
| php_yaz.dll | YAZ 函数库 | 需要:yaz.dll(已附带) |
| php_zip.dll | Zip 文件函数库 | 只读访问 |
| php_zlib.dll | ZLib 压缩函数库 | 自 PHP 4.3.0 起内置 |
Windows 下安装扩展库
04-May-2009 04:39
13-Dec-2008 11:40
After upgrading to PHP5 with Apache 2.2.10 on windows server 2003 I was having troubles with the error saying Fatal error: call to undefined function - mysql_connect().
I had done everything I could think of or find on the internet and was still having the same error show up.
I then ran the phpinfo() function and it showed I was reading the correct php.ini from my C:/PHP/ path and it showed a mysql version.
The problem was it loaded the mysql files in my system32 directory which were from an earlier version. I simply removed these files from my system32 directory and it had fixed the problem since I had everything else correctly setup.
02-Dec-2008 04:12
Make sure your php.ini file is read at all.
I had the problem that on a Windows 2003 Server the php.ini was not read, so only default values were used resulting in no extension modules to work, because they do not reside in C:\PHP5 but in D:\PHP\ext.
The output of phpinfo() told me the "Configuration File (php.ini) Path" was "C:\WINDOWS".
Well this sounded good to me because I had copied the php.ini file from D:\PHP to C:\WINDOWS.
But a path to a directory as a value of "Configuration File (php.ini) Path" instead of the full path to the php.ini file you expect to be read means that NO php.ini file could be found so that the default values are used.
What fixed the problem was adding a System variable "PHPRC" set to the path to the directory where the php.ini file is to be found.
After rebooting the Server everything was fine - the extension_dir was set correctly and after all I succeeded in connecting to my MySQL-Database-Server.
:-)
http://www.php.net/manual/en/faq.installation.php
#faq.installation.findphpini
08-Oct-2008 01:01
I just recently tried to upgrade my php install on WinXP using the php-5.2.6-win32-installer.msi and with fingers crossed, tried to see if things still worked or not.
Unfortunately, they didn't. I did see many posts here and elsewhere on the web regarding the error message:
"Unable to load dynamic link library 'ext\php_xxxxx.dll' - The specified module could not be found."
php.net says in the past when upgrading to simply copy over new php files, but now recommends using the windows installer. Maybe the installer isn't quite up to the task yet.
My fix:
1. Completely uninstall current version of php (using Windows Control Panel > Add or Remove Programs).
2. Download the current php binaries for Windows (at php.net/downloads.php under Windows Binaries). Should be format: PHP 5.x.x zip package. Again, download the binaries, NOT the installer.
3. Follow these easy steps
http://www.ricocheting.com/server/php.html
4. Set your PATH for Windows to find php (if you haven't already):
a. Right-click on My Computer
b. Properties
c. Advanced Tab > Environment Variables
d. Under System variables, scroll down to find "Path", select and click on Edit
e. Add path to your php install on the end (make sure to precede with semi-colon ";"). Mine was ";G:\Apache\php"
f. Click Okay. (then "Okay" on each of the other open windows).
5. Test php install. (see ricocheting link above for testing).
6. Getting the extensions to work again:
a. Open php.ini
b. uncomment each extension, restart Apache.
7. Special note on libmysql.dll and problems getting MySQL to work:
- You may have copied over this file into your Windows/System32 (or WINNT/System32 for me) to get mysql to work in the past. If so, replace it with the most recent version you get with the upgrade (in top dir).
- If this is a fresh install, copy the libmysql.dll into your System32 folder.
Couple notes:
1. The above tutorial link is to install php 5.x on Apache 2.2 for Win. If you're running Apache 2.0 like me, pay special attention to "Editing Apache Conf File" for correct LoadModule info.
2. If you ran the installer previously, double check your Apache conf where the php5 LoadModule stuff is. The installer might have messed with this a bit.
I hope this stuff helps.
-Art
17-Jul-2008 09:06
If you are having trouble getting extensions to run and changes to php.ini don't seem to make a jot of difference you may find that your php.ini is not being read and you are running on defaults.
The good news is that Elsint's fix (dated 26-Sep-2006) still works for php 5.2.6 under Windows Server 2003 SP2, on IIS6, running php as an ISAPI module.
Diagnostic:
run a test file
<php
phpinfo();
?php>
Load this in a browser and search the results for "Loaded Configuration File". This points to the .ini file in use, which I have found is not always the one I have been editing ...
If your problem is with extensions: search for extension_dir in the phpinfo() results. If the entry which follows is C:\PHP5, or some other directory which does not exist on your drive you may need the registry fix. The alternative is to put the php.ini file somewhere along the search path, but this is not quite as clean.
Background:
If you run the installer packages: php-5.2.5-win32-installer.msi or php-5.2.6-win32-installer.msi and choose the default install directory the following registry entires are added
HKEY_LOCAL_MACHINE
SOFTWARE
PHP
InstallDir REG_SZ C:\Program Files\PHP\
WebServerType REG_SZ iis4ISAPI
However, the installers above do not create the IniFilePath registry entry.
So: you either go for a direct registry hack or create and run a registry file named: "[whatever].reg"
If your install directory is the default for the above installers the contents should be the 4 (four) lines below (counting the blank one!) between the pseudo tags.
<whatever.reg>
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\Program Files\\PHP"
</whatever.reg>
(Note you have to have the double backslashes for the .reg file to work even though Windows reports it worked without them).
Once you have the new registry key in place you may find it sufficient to restart the World Wide Web Publishing Service, which is also restarted if you take the slightly longer option of restarting the IIS Admin Service.
If this works for you and you want to backtrack by undoing the registry changes to test if this was the fix that did it: you may need a reboot (not just a service restart) because of some rather irritating persistencies.
07-Jun-2008 06:46
If you get errors like this:
PHP Notice: Constant XML_ELEMENT_NODE already defined in Unknown on line 0
And many more complaining about XML constants, comment out the line:
extension=php_domxml.dll
in your php.ini. That extension seems to be compiled into PHP when you get those errors or something else is including the functionality before that dll.
15-Feb-2008 10:51
== Problem
Consider the following from an httpd.conf file...
LoadModule php5_module "E:/xyz/php/php5apache2_2.dll"
PHPIniDir "E:/xyz/php"
...which led to the dreaded...
PHP Warning: PHP Startup: Unable to load dynamic library 'E:\\xyz\\php\\ext\\php_mysql.dll' - The specified module could not be found.
Note, however, that PHP.exe apparently was found and executed php pages in Apache, but the MySQL functions therein failed.
== Solution
Because PHP dir was not in $PATH, php5apache2_2.dll failed to find php_mysql.dll (the only extension I enabled) during Apache 2.2 start.
== Caveat (!)
The BIG issue is that, setting $PATH in...
<desk icon>My Computer
<rt click>Properties
<tab>Advanced
<button>Environment Variables
...didn't export the $PATH change such that restarting the Apache service (in MMC) would pick it up. So I tested the working solution (adding PHP dir to $PATH), but it failed because of HOW I set it. It succeeded only when I REBOOTED after changing the $PATH. There may be an easier way that this, but I do not know it at present.
== Comment
Consider whether PHP dir should need to be in $PATH at all, when PHP.exe apparently was found and executes php pages in Apache, but php5apache2_2.dll failed to find whatever was needed to load the extensions. This should perhaps be addressed.
Note that on a WAMP installation (W2K,Apache,MySQL,PHP), only PHP is required in $PATH.
30-Jan-2008 12:10
As far as my experience says, 95% of ext\php_mysql.dll - The specified module could not be found - error can be sorted out on Win 2003, IIS 6, PHP5.2.
Replace the php_mysql.dll and libmysql.dll downloaded from http://dev.mysql.com/downloads/connector/php/ into extensions directory.
For MSSQL connectivity problems, replace the ntwdblib.dll in php dir with the one copied from system32 directory. Ofcourse the filesize will be less, no problem, replace it.
22-Sep-2007 12:00
Under windows, given an error similar to
PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
When PHP definitely should be able to find the module, it's fairly common knowledge that this error can also be caused by certain dlls not being in the PATH. These dlls (usually libeay32 and ssleay32) are generally found in your base php directory, and the modern windows installers add the base php directory to the PATH so that you don't need to worry about it. However, if when installing earlier versions you decided on moving libeay32, ssleay32 et al to C:\Windows\System32 instead of changing the PATH, then php will still end up with the old versions and the out of date versions will cause the same error as above. Don't fall into the trap like I did.
30-Aug-2007 08:12
Installing PHP extensions for IIS for the first time is sort of a baptism by fire -- you will get your hands dirty, and other suitable metaphors of nastiness. Hopefully, you won't have to spend too many days googling around fora and restarting IIS 10 million times as I did until I finally realized both what was going on and what crazy things I'd done wrong.
THIS (peter)guy really goes into terrific detail and troubleshooting, (with very good reasons and explanations of extension dependencies not listed on the current php page you're now reading):
http://www.peterguy.com/php/install_IIS6.html
Most of this is applicable for IIS5.1 as well, as far as I've found.
The main problem I'd been butting my head up against was extensions being reported as not found, even though the .DLLs were definitely in C:\PHP\ext, and my PATH env var was setup correctly.
The error messaging during dynamic loading of implicitly-linked libraries should be more specific, telling you that in fact it is a particular dependency of a dependency which is missing -- usually some obscure third-party .dll -- and name it!
Eventually I stopped being so greedy and just cut down on the extensions I thought I needed by commenting them out in php.ini. That eliminated the startup errors. Apparently some of these extensions or their requirements, which either come with the base PHP install zip or the PECL extensions, are either too obscure or too fragile to be necessary anyway.
Good luck, and I hope anyone who runs into the same trouble can hit upon this or Peter Guy's page directly before they go too crazy.
13-Feb-2007 08:51
When confronted with the problem "PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll' - Access is denied.\r\n in Unknown on line 0" I found I had to make the permissions "chmod.exe 755 php_mysql.dll"
(This is on a Windows XP, but I am running Cygwin).
15-Nov-2006 09:10
I just installed PHP5.2 + Apache2.2 + MySQL5 on Windows XP. Three imporatant things.
1. I tryed to put php.ini in windows directory like in early version. But php can't load it and using default values only. After I put php.ini into php installation directory, everything is fine.
2. You still need to copy libmysql.dll to windows\system32 directory for the mysql extension to work.
3. Don't forget for apache 2.2, you need php5apache2_2.dll instead of php5apache2.dll.
12-Oct-2006 01:11
We tried to install PHP 4 ISAPI Module on IIS 6 on a Windows Server 2003 SP2 at the office.
The only way we found out to make these extensions work, is by putting the extensions DLLs in the System32\inetsrv in the Windows directory. We did the same previously with the
php4isapi.dll and php4ts.dll to make PHP work. The system was asking for a password previously.
We cannot explain it, it seems like a problem only occuring with SP2 installed because we never had this problem before. Giving the right permission to the PHP and extensions folders didn't do anything good. It always gave use a permission denied error. We even tried to give full control to Everyone on the PHP folder, same result.
I hope it can help.
26-Sep-2006 06:38
Installing PHP5.1.6 on an IIS5.1 system.
Some extensions are not working because of registry(like LDAP).
You need to create a registry file named: "inifilepath.reg"
Content should be the 3 lines under,be sure to define your PHP path correct:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP"
After creating this file, double click it, click yes, and restart IIS. Hopefully this might solve problem for some, as it solved for me.
17-Aug-2006 08:10
I had problems with PHP5/Apache2.2/MySQL 5 installation on a WinXp machine.
I got the
Fatal error: call to undefined function - mysql_connect().
message
Solution :
1, use correct version of ext\php_mysql.dll and libmysql.dll
2, !!! edit the CORRECT php.ini (%windir%\php.ini) like c:\windows\php.ini !!!
3, add php installation dir to PATH
4, edit php.ini to load extension php_mysql.dll
use
<?php
phpinfo();
?>
to check.
07-Apr-2006 08:54
If You try to install PHP5 to IIS6 with Oracle....
Then You need some kind of pilot-exams, not for big planes, just a little one.
So: After installations (php.ini is correct see above ie.: extenstion = php_oci8.dll etc)
If You use anonymous access, You'll have a builtin user to use it. Make this user local administrator, or give minimum read access to PHP folder (ie.: c:\php) and ORAHOME (ie. c:\ora92) folders.
If You use Windows Integrated authentication, give for Domain Users minimum read access to PHP folder (ie.: c:\php) and ORAHOME (ie. c:\ora92) folders.
Goog luck.
19-Aug-2004 04:35
[editor note: this should be fixed in PHP 5.1.0]
The order of the extensions listed in php.ini is causing problems... one must check that a particular extension A is enabled and above extension B if B requires A to be enabled.
The original ordering doesnt make sure that this always happens (ie, A is above B)
I came into this problem when I tried to enable the exif extension under windows. I knew mbstring is required but I kept getting errors even after I enabled both.
The problem can only be fixed by moving the mbstring line above the exif line...
