经过几个小时的寻找,我在这里寻求帮助。我在更新我的Web服务器后遇到了问题:PHP和Apache我有一台测试机器(Win10)和生产(Server 2016)。两者都有相同的WEB配置,除了WINSRV 2016有Postgres 14和win10有Postgres 15。我使用不同版本的 * libpq.dll *,基于postgres安装文件夹 bin。
问题是在WINSRV 2016上(仅在CMD中),动态库不会加载:
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
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
因此,当使用CMD启动php时出现错误,Apache日志中没有错误。web服务器加载pgsql表没有问题。这种情况只发生在WINSRV 2016上。在WIN10上,CMD中没有错误。
在两台计算机上运行的版本是:
Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/7.3.7RC3
两台计算机上的php.ini:
...
;extension=bz2
;extension=curl
extension=fileinfo
extension=gd2
;extension=gettext
;extension=gmp
extension=intl
extension=imap
;extension=interbase
;extension=ldap
extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
;extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
;extension=pdo_mysql
;extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
;extension=pdo_sqlite
extension=pgsql
;extension=shmop
extension=php_pdo_sqlsrv_73_ts_x64
extension=php_sqlsrv_73_ts_x64
...
两台电脑上的httpd.conf:
...
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule xml2enc_module modules/mod_xml2enc.so
LoadFile "D:/WEB_Server/PostgreSQL/14/bin/libpq.dll"
LoadModule php7_module "D:/WEB_Server/PHP/php7apache2_4.dll"
...
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的输出:
D:\WEB_Server\PHP>php -m
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
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
[PHP Modules]
bcmath
calendar
Core
ctype
date
dom
fileinfo
filter
gd
hash
iconv
imap
intl
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
PDO_ODBC
pdo_sqlsrv
Phar
readline
Reflection
session
SimpleXML
SPL
sqlsrv
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
php -v:
D:\WEB_Server\PHP>php -v
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
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
PHP 7.3.7RC3 (cli) (built: Jun 20 2019 16:57:39) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.7RC3, Copyright (c) 1998-2018 Zend Technologies
请告诉我如果你需要更多的信息。我会编辑这个问题。谢谢.
1条答案
按热度按时间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()中更新它。