apache PHP警告:PHP启动:无法加载模块:Public到这里去看看!

hm2xizp9  于 2023-10-23  发布在  Apache
关注(0)|答案(1)|浏览(273)

经过几个小时的寻找,我在这里寻求帮助。我在更新我的Web服务器后遇到了问题:PHP和Apache我有一台测试机器(Win10)和生产(Server 2016)。两者都有相同的WEB配置,除了WINSRV 2016有Postgres 14和win10有Postgres 15。我使用不同版本的 * libpq.dll *,基于postgres安装文件夹 bin
问题是在WINSRV 2016上(仅在CMD中),动态库不会加载:

  1. PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried:
  2. D:\WEB_Server\PHP\ext\pdo_pgsql (The specified module could not be found.),
  3. D:\WEB_Server\PHP\ext\php_pdo_pgsql.dll (The specified module could not be found.)) in Unknown on line 0
  4. PHP Warning: PHP Startup: Unable to load dynamic library 'pgsql' (tried:
  5. D:\WEB_Server\PHP\ext\pgsql (The specified module could not be found.),
  6. D:\WEB_Server\PHP\ext\php_pgsql.dll (The specified module could not be found.)) in Unknown on line 0

因此,当使用CMD启动php时出现错误,Apache日志中没有错误。web服务器加载pgsql表没有问题。这种情况只发生在WINSRV 2016上。在WIN10上,CMD中没有错误。
在两台计算机上运行的版本是:

  1. Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/7.3.7RC3

两台计算机上的php.ini:

  1. ...
  2. ;extension=bz2
  3. ;extension=curl
  4. extension=fileinfo
  5. extension=gd2
  6. ;extension=gettext
  7. ;extension=gmp
  8. extension=intl
  9. extension=imap
  10. ;extension=interbase
  11. ;extension=ldap
  12. extension=mbstring
  13. ;extension=exif ; Must be after mbstring as it depends on it
  14. ;extension=mysqli
  15. ;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
  16. ;extension=odbc
  17. extension=openssl
  18. ;extension=pdo_firebird
  19. ;extension=pdo_mysql
  20. ;extension=pdo_oci
  21. extension=pdo_odbc
  22. extension=pdo_pgsql
  23. ;extension=pdo_sqlite
  24. extension=pgsql
  25. ;extension=shmop
  26. extension=php_pdo_sqlsrv_73_ts_x64
  27. extension=php_sqlsrv_73_ts_x64
  28. ...

两台电脑上的httpd.conf:

  1. ...
  2. LoadModule ssl_module modules/mod_ssl.so
  3. LoadModule status_module modules/mod_status.so
  4. #LoadModule substitute_module modules/mod_substitute.so
  5. #LoadModule unique_id_module modules/mod_unique_id.so
  6. #LoadModule userdir_module modules/mod_userdir.so
  7. #LoadModule usertrack_module modules/mod_usertrack.so
  8. #LoadModule version_module modules/mod_version.so
  9. #LoadModule vhost_alias_module modules/mod_vhost_alias.so
  10. #LoadModule watchdog_module modules/mod_watchdog.so
  11. #LoadModule xml2enc_module modules/mod_xml2enc.so
  12. LoadFile "D:/WEB_Server/PostgreSQL/14/bin/libpq.dll"
  13. LoadModule php7_module "D:/WEB_Server/PHP/php7apache2_4.dll"
  14. ...
  15. PHPIniDir "D:\WEB_Server\PHP"

我测试过:

  • 如果我在php.ini中注解了两个pg扩展,apache将停止使用这些模块。
  • 我没有任何其他php.ini在该服务器上。
  • 奇怪的是,在两台机器上,phpinfo都说PostgreSQL(libpq)使用的是PostgreSQL 9.6.12(win32),但它分别指向15.1和14.3版本的文件。

php -m的输出:

  1. D:\WEB_Server\PHP>php -m
  2. PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: D:\WEB_Server\PHP\ext\pdo_pgsql (The specified module could not be found.), D:\WEB_Server\PHP\ext\php_pdo_pgsql.dll (The specified module could not be found.)) in Unknown on line 0
  3. PHP Warning: PHP Startup: Unable to load dynamic library 'pgsql' (tried: D:\WEB_Server\PHP\ext\pgsql (The specified module could not be found.), D:\WEB_Server\PHP\ext\php_pgsql.dll (The specified module could not be found.)) in Unknown on line 0
  4. [PHP Modules]
  5. bcmath
  6. calendar
  7. Core
  8. ctype
  9. date
  10. dom
  11. fileinfo
  12. filter
  13. gd
  14. hash
  15. iconv
  16. imap
  17. intl
  18. json
  19. libxml
  20. mbstring
  21. mysqlnd
  22. openssl
  23. pcre
  24. PDO
  25. PDO_ODBC
  26. pdo_sqlsrv
  27. Phar
  28. readline
  29. Reflection
  30. session
  31. SimpleXML
  32. SPL
  33. sqlsrv
  34. standard
  35. tokenizer
  36. wddx
  37. xml
  38. xmlreader
  39. xmlwriter
  40. zip
  41. zlib
  42. [Zend Modules]

php -v:

  1. D:\WEB_Server\PHP>php -v
  2. PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: D:\WEB_Server\PHP\ext\pdo_pgsql (The specified module could not be found.), D:\WEB_Server\PHP\ext\php_pdo_pgsql.dll (The specified module could not be found.)) in Unknown on line 0
  3. PHP Warning: PHP Startup: Unable to load dynamic library 'pgsql' (tried: D:\WEB_Server\PHP\ext\pgsql (The specified module could not be found.), D:\WEB_Server\PHP\ext\php_pgsql.dll (The specified module could not be found.)) in Unknown on line 0
  4. PHP 7.3.7RC3 (cli) (built: Jun 20 2019 16:57:39) ( ZTS MSVC15 (Visual C++ 2017) x64 )
  5. Copyright (c) 1997-2018 The PHP Group
  6. Zend Engine v3.3.7RC3, Copyright (c) 1998-2018 Zend Technologies

请告诉我如果你需要更多的信息。我会编辑这个问题。谢谢.

bybem2ql

bybem2ql1#

刚刚解决了问题。
1.所以CLI使用的是PHP根目录下的libpq.dll,与pgSQL服务器存在版本冲突。我已经将PostgreSQL 14中的libpq复制到PHP文件夹中,并在WINSRV 2016上替换了旧版本。这招奏效了!在此之后,我试图在工作服务器上替换文件Win10,看看是否会工作。但它得到错误,我恢复的变化。
1.对于phpinfo中libpq(9.6)的旧版本。我更新了php到libpq 11.4附带的7.4.8。现在phpinfo使用的是11.4。奇怪的是,如果我用任何其他较新的版本替换它,它不会在CLI和Web上的phpinfo()中更新它。

相关问题