如何解决PHP startup: Unable to load dynamic library的错误

本文主要讲述了PHP扩展依赖的DLL文件加载出错的问题。以php_mysql.dll为例,因PHP安装目录变更且未将新目录添加到%PATH%,导致依赖的libmysql.dll无法找到。给出两种解决办法:将依赖的dll拷贝到%windir%/system32下或把PHP安装目录添加到%PATH%,还列出了各扩展依赖的dll。
转!



怪啦!今天的Apache和IIS都没法正确加载php_mysql.dll。google了一下,原来发现出现这个问题的人还不少,PHP startup: Unable to load dynamic library :E;/PHP5/ext/php_mysql.dll。明明php_mysql.dll就摆在extension_dir (= "E:/PHP5/ext")下的嘛,怎么会呢?而且就在php_mysql.dll之前的extension=php_gd2.dll都没有出现这个问题,怪了!有人说copy libmysql.dll到 %windir%/system32下就可以解决问题,其实"华山不这一条道":

 

PHP被我挪了个窝,%ProgramFiles%到E:/下,导致一些要依赖于其他dll才能工作的扩展无法正常加载这些dll,出现加载扩展出
错,以刚才的php_mysql.dll为例,php_mysql依赖libmysql.dll,由于给PHP5挪窝了,而又没有把新的E:/PHP5夹道%PATH%中去
,所以没法找到这个libmysql.dll,才会出错。所以为了能够使用这些mysql的扩展,除了要正确地配置extension_dir外
,还得保证系统能够这些扩展所依赖的dll,解决的办法有两个:
1 将这些依赖的dll拷贝到%windir%/system32下
2 或者将PHP5的安装目录添加到%PATH%中
无论那个都可以很好地达到我们地目的。
够简单的,但是有时候还就想不到哪儿去。
到底哪些扩展依赖哪些dll呢?以下列表可以帮助我们回答这个问题:
php_curl.dll CURL, Client URL library functions Requires:   libeay32.dll, ssleay32.dll (bundled)
php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll
   (bundled) PHP >= 4.3.0 requires: iconv.dll (bundled)
php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll
gnu_gettext.dll (bundled), PHP >= 4.2.3 requires libintl-1.dll,
php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll
php_ingres.dll Ingres II functions Requires: Ingres II libraries
php_interbase.dll InterBase functions Requires: gds32.dll (bundled)
php_java.dll Java functions PHP <= 4.0.6 requires: jvm.dll (bundled)
php_ldap.dll LDAP functions PHP <= 4.2.0 requires libsasl.dll(bundled),
     PHP >= 4.3.0 requires libeay32.dll,ssleay32.dll (bundled)
php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll   (bundled)
php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll   (bundled)
php_msql.dll mSQL functions Requires: msql.dll (bundled)
php_mssql.dll MSSQL functions Requires: ntwdblib.dll (bundled)
php_mysql.dll MySQL functions PHP >= 5.0.0, requires libmysql.dll   (bundled)
php_mysqli.dll MySQLi functions PHP >= 5.0.0, requires libmysqli.dll   (bundled)
php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries
php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled)
php_oracle.dll Oracle functions Requires: Oracle 7 client libraries
php_sybase_ct.dll Sybase functions Requires: Sybase client libraries
php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll   (bundled)
php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll,  expat.dll (bundled).
        PHP >= 4.2.1 requires sablot.dll, expat.dll,  iconv.dll (bundled).

看文档耐心不够,自己找了点麻烦。:P




PHP 在启动时提示 `Unable to load dynamic library 'gmp'` 错误,通常意味着 PHP 无法加载 GMP 扩展。这个问题可能由多个原因引起,包括扩展文件路径配置错误、GMP 库未正确安装或与当前 PHP 版本不兼容等。 ### 原因分析与解决方法 1. **确认 GMP 扩展是否已安装** 如果使用的是 Linux 系统,可以尝试通过包管理器安装 GMP 扩展。例如,在基于 Debian 的系统上运行以下命令: ```bash sudo apt-get install php-gmp ``` 安装完成后,确保在 `php.ini` 文件中启用了 GMP 扩展: ```ini extension=gmp ``` 2. **检查扩展路径和配置** 在某些情况下,`php.ini` 中的 `extension_dir` 设置可能不正确,导致 PHP 无法找到 `gmp.so`(Linux)或 `php_gmp.dll`(Windows)文件。可以通过以下方式验证并修复: - 查看当前的 `extension_dir` 配置: ```bash php -i | grep extension_dir ``` - 确保该目录下存在 GMP 扩展文件。 - 如果路径不正确,可以在 `php.ini` 中手动设置正确的路径: ```ini extension_dir = "/usr/lib/php/20210902" ``` 3. **重新编译 PHP 并启用 GMP** 如果是自行编译 PHP,并且希望启用调试功能,可以按照以下步骤操作[^1]: - 在执行 `configure` 脚本时,移除 `--disable-debug` 参数,并添加 `--enable-debug` 和 `--enable-mysqlnd=shared`: ```bash ./configure --enable-debug --enable-mysqlnd=shared --with-gmp ``` - 确保系统中已经安装了 GMP 开发库。在 Debian/Ubuntu 上可以运行: ```bash sudo apt-get install libgmp-dev ``` - 编译并安装 PHP: ```bash make && sudo make install ``` 4. **检查依赖库版本兼容性** 如果 GMP 扩展已经安装但仍然报错,可能是由于 GMP 库版本与 PHP 不兼容。可以尝试更新 GMP 库到最新版本: ```bash sudo apt-get update sudo apt-get upgrade libgmp-dev ``` 5. **查看日志以获取更多线索** PHP 启动时的日志可能会提供更多关于加载失败的信息。可以检查 `php_error_log` 或系统日志(如 `/var/log/apache2/error.log` 或 `/var/log/php-fpm.log`),查找类似以下内容: ``` PHP Warning: PHP Startup: Unable to load dynamic library 'gmp' (tried: /usr/lib/php/20210902/gmp (/usr/lib/php/20210902/gmp: undefined symbol: zif_gmp_init), /usr/lib/php/20210902/gmp.so (cannot open shared object file: No such file or directory)) ``` 根据提示信息进一步排查问题。 --- ###
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值