找回密码
 新建账号

PHP Startup: Unable to load dynamic library fileinfo sqlite3 mysqli pdo_mysql

[复制链接]
php 发表于 2024/5/10 04:40 | 显示全部楼层 |阅读模式
动态编译 PHP 8.3 扩展后运行 PHP 时报出了以下错误
  1. wuxiancheng@wuxiancheng.cn:~$ php -d display_errors=On -d display_startup_errors=On -r "echo 1;"
复制代码
  1. Warning: PHP Startup: Unable to load dynamic library 'fileinfo' (tried: /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/fileinfo (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/fileinfo: cannot open shared object file: No such file or directory), /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/fileinfo.so (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/fileinfo.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

  2. Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/pdo_sqlite (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/pdo_sqlite: cannot open shared object file: No such file or directory), /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/pdo_sqlite.so (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/pdo_sqlite.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

  3. Warning: PHP Startup: Unable to load dynamic library 'sqlite3' (tried: /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/sqlite3 (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/sqlite3: cannot open shared object file: No such file or directory), /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/sqlite3.so (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/sqlite3.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

  4. Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/mysqli (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/mysqli: cannot open shared object file: No such file or directory), /opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/mysqli.so (/opt/php/8.3/lib/php/extensions/no-debug-non-zts-20230831/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0

  5. Warning: Cannot load module "pdo_mysql" because required module "mysqlnd" is not loaded in Unknown on line 0
  6. 1
复制代码
PHP 8.3 fileinfo pdo_sqlite sqlite3 默认编译进了 PHP Core,不需要作为扩展加载,因为扩展目录已经没有 sqlite3.so pdo_sqlite.so sqlite3.so 这些文件,在 Windows 上,PHP 扩展的文件名通常以 .dll 结尾,而不是以 .so 结尾,如果还将它们作为扩展加载,就会触发 Unable to load dynamic library 的错误,解决方法是将生效的 php.ini 中的以下配置条目删除掉或者注释掉。
  1. extension = fileinfo
  2. extension = pdo_sqlite
  3. extension = sqlite3
复制代码
对于 mysqli pdo_mysql 扩展,在 PHP 扩展目录中有 mysqli.so pdo_mysql.so,还有一个 mysqlnd.so,实际上错误信息已经指出 mysqlnd 扩展没有加载,而 mysqli 和 pdo_mysql 依赖于 mysqlnd,解决方法就是加载 mysqlnd 扩展,而且要在加载 mysqli 和 pdo_mysql 扩展之前加载。
  1. extension = mysqlnd
  2. extension = mysqli
  3. extension = pdo_mysql
复制代码
以上问题实际上是 PHP 官方挖的一个坑,PHP 官方提供的 php.ini 模板文件包含了加载 fileinfo pdo_sqlite sqlite3 这三个不需要加载的扩展的配置条目,而需要加载的扩展 mysqlnd 却没有包含在内。如果静态编译 PHP 扩展,因为扩展已经编译进 PHP 的二进制文件中,运行时不需要从扩展目录加载扩展文件。

手机版|轻松E站

GMT+8, 2024/5/19 06:25

快速回复 返回顶部 返回列表