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

bakd9h0s  于 2023-03-16  发布在  PHP
关注(0)|答案(7)|浏览(116)

我目前在Windows Server 2008 R2上安装了PHP 5. 5. 12和Apache 2. 4。一切运行完美,没有任何问题/警告。
我所做的是将相同的Apache文件/配置复制到另一台服务器上。我复制了C:\PHP目录,然后复制了C:\Apache24目录,并将它们粘贴到新服务器上。
然后我安装了Apache,做了一个更改(即httpd -k install)。我将端口号从80更改为8877。Apache工作正常,运行在8877端口上。我也可以通过转到SERVER_IP_ADDRESS:8877打开默认页面,它工作正常。
但是,PHP没有正常工作。在Apache服务器的error.log文件中,我收到了下面列出的警告

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启动问题?

htrmnn0y

htrmnn0y1#

正如Darren所评论的,Apache不理解Windows中的php.ini相对路径。
要解决这个问题,请将php.ini中的相对路径更改为绝对路径。

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

mfuanj7w2#

使用绝对路径:

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

3pvhb19x3#

如果您使用的是laragon,请打开php.ini
在laragon菜单-〉php-〉php.ini界面
打开文件时,查找**;扩展目录=“./"**
创建另一个没有的;用你的php版本的路径到文件夹ext例如

extension_dir = "C: \ laragon \ bin \ php \ php-7.3.11-Win32-VC15-x64 \ ext"

更改保存

clj7thdc

clj7thdc4#

1.检查是否正确安装了与您的PHP版本兼容的Mysql。(* 例如,mysql-installer-community-5.5.40.1.msi适用于PHP 5.2.10,apache 2.2和phpMyAdmin 3.5.2*)
1.在你的php\php.ini中设置你的可加载php扩展路径(例如extension_dir = "C:\php\ext")(https://drive.google.com/open?id=1DDZd06SLHSmoFrdmWkmZuXt4DMOPIi_A
1.(在您的php\php.ini中)检查extension=php_mysqli.dll是否未注解https://drive.google.com/open?id=17DUt1oECwOdol8K5GaW3tdPWlVRSYfQ9
1.将php文件夹(例如"C:\php")和php\ext文件夹(例如"C:\php\ext")设置为运行时环境变量路径https://drive.google.com/open?id=1zCRRjh1Jem_LymGsgMmYxFc8Z9dUamKK
1.重新启动Apache服务(https://drive.google.com/open?id=1kJF5kxPSrj3LdKWJcJTos9ecKFx0ORAW

uoifb46i

uoifb46i5#

也许对某人有用,我在Windows 8,Apache 2. 4,PHP 7+上遇到了下一个问题。

php.ini conf>

extension_dir="C:/Server/PHP7/ext"

php在apache上工作正常,但在cli上加载库时出现问题,因此,我更改为

extension_dir="C:/server/PHP7/ext"
cfh9epnr

cfh9epnr6#

在提示用途:

dir /x

在“Program Files(x86)行”中查找目录的简化名称

27/08/2018  15:07    <DIR>          PROGRA~2     Program Files (x86)

php.ini中为该选项输入以下配置:

extension_dir="C:\PROGRA~2\path\to\php\ext"
mzaanser

mzaanser7#

对我来说,我导入扩展本身的方式是错误的:

错误的方向

extension="C:/Bitnami/wampstack-7.4.7-0/php/ext/bolt.so"

正确的道路

extension=bolt

相关问题