如何修复PHP警告:PHP启动:无法加载动态库“ext\\php_curl.dll”?

2022-08-30 13:23:25

我目前在Windows Server 2008 R2上安装了PHP 5.5.12和Apache 2.4。一切都运行良好,没有问题/警告。

我所做的是将相同的Apache文件/配置复制到另一台服务器。我复制了目录,然后复制了目录,并将它们粘贴到新服务器中。C:\PHPC:\Apache24

然后我安装了Apache,只有一个更改(即.我将端口号从80更改为8877。Apache正在正常工作,它在8877端口上运行。我也可以通过转到SERVER_IP_ADDRESS:8877打开默认页面,它可以正常工作。httpd -k install

但是,PHP并没有像它应该的那样工作。在错误中.log来自Apache服务器的文件,我得到下面列出的警告

PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_curl.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_ldap.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_openssl.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_pdo_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_sqlsrv_55_ts.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ext\\php_pdo_sqlsrv_55_ts.dll' - The specified module could not be found.\r\n in Unknown on line 0

我似乎无法弄清楚为什么我会收到此错误?警告指出“找不到指定的模块”的所有.dll文件都存在于 C:\PHP\ext 目录php 中

PHP 扩展位于

C:\php\ext

在文件php内部.ini我有这个变量

extension_dir = "ext"

这里是 ext 文件夹的目录列表

 Volume in drive C is OS
 Volume Serial Number is C63C-1D75

 Directory of C:\php\ext

07/29/2014  06:42 PM    <DIR>          .
07/29/2014  06:42 PM    <DIR>          ..
04/30/2014  02:46 PM            66,560 php_bz2.dll
04/30/2014  02:46 PM            72,704 php_com_dotnet.dll
04/30/2014  02:46 PM           507,392 php_curl.dll
04/30/2014  02:46 PM            18,944 php_enchant.dll
04/30/2014  02:46 PM            43,008 php_exif.dll
04/30/2014  02:46 PM         2,679,808 php_fileinfo.dll
04/30/2014  02:46 PM         1,358,848 php_gd2.dll
04/30/2014  02:46 PM            40,960 php_gettext.dll
04/30/2014  02:46 PM           240,128 php_gmp.dll
04/30/2014  02:46 PM           831,488 php_imap.dll
04/30/2014  02:46 PM            65,024 php_interbase.dll
04/30/2014  02:46 PM           261,632 php_intl.dll
04/30/2014  02:46 PM           179,200 php_ldap.dll
04/30/2014  02:46 PM         1,239,552 php_mbstring.dll
04/30/2014  02:46 PM            36,864 php_mysql.dll
04/30/2014  02:46 PM            88,576 php_mysqli.dll
04/30/2014  02:46 PM           141,824 php_oci8.dll
04/30/2014  02:46 PM           142,336 php_oci8_11g.dll
04/30/2014  02:46 PM           120,320 php_opcache.dll
04/30/2014  02:46 PM            72,704 php_openssl.dll
04/30/2014  02:46 PM            21,504 php_pdo_firebird.dll
04/30/2014  02:46 PM            24,576 php_pdo_mysql.dll
04/30/2014  02:46 PM            23,040 php_pdo_oci.dll
04/30/2014  02:46 PM            20,480 php_pdo_odbc.dll
04/30/2014  02:46 PM            27,648 php_pdo_pgsql.dll
04/30/2014  02:46 PM           465,408 php_pdo_sqlite.dll
08/28/2012  04:15 PM           186,520 php_pdo_sqlsrv_54_ts.dll
06/26/2013  03:22 PM           166,400 php_pdo_sqlsrv_55_ts.dll
04/30/2014  02:46 PM            90,112 php_pgsql.dll
04/30/2014  02:46 PM            12,288 php_shmop.dll
04/30/2014  02:46 PM           385,536 php_snmp.dll
04/30/2014  02:46 PM           236,544 php_soap.dll
04/30/2014  02:46 PM            54,784 php_sockets.dll
04/30/2014  02:46 PM           617,472 php_sqlite3.dll
08/28/2012  04:15 PM           204,952 php_sqlsrv_54_ts.dll
06/26/2013  03:22 PM           183,296 php_sqlsrv_55_ts.dll
04/30/2014  02:46 PM            31,744 php_sybase_ct.dll
04/30/2014  02:46 PM           236,544 php_tidy.dll
04/30/2014  02:46 PM            51,712 php_xmlrpc.dll
04/30/2014  02:46 PM           231,936 php_xsl.dll
              40 File(s)     11,480,368 bytes
               2 Dir(s)  83,103,895,552 bytes free

当我尝试访问网站时,我收到此错误

致命错误:未定义的类常量“MYSQL_ATTR_INIT_COMMAND”

这是因为未加载扩展。

我假设配置是正确的,因为相同的配置在不同的服务器上工作。

如何解决此 PHP 启动问题?


答案 1

正如Darren所评论的那样,Apache不了解Windows中的相对路径。php.ini

要解决此问题,请将路径中的相对路径更改为绝对路径。php.ini

extension_dir="C:\full\path\to\php\ext\dir"

答案 2

使用绝对路径:

extension_dir="C:\full\path\here"

推荐