apache+mysql 常见错误

Visits: 0

故障背景

错误环境:

新下载的apache+mysql环境,新下载的wordpress,搭建单机测试环境。然后访问wordpress的网站根目录,然后报错。

报错现象

报错如下:

报错分析

很困惑,很确定,mysqli已经在php当中启用了。

找不到原因,那就查看日志,日志路径:"D:\My_WebSite\System\httpd-2.4.55-o111s-x64-vs17\Apache24\logs\error.log",打开日志后,发现报错内容:

[Sat Mar 16 14:50:35.214304 2024] [core:notice] [pid 8800:tid 340] AH00094: Command line: 'D:\\My_WebSite\\System\\httpd-2.4.55-o111s-x64-vs17\\Apache24\\bin\\httpd.exe -d D:/My_WebSite/System/httpd-2.4.55-o111s-x64-vs17/Apache24'
[Sat Mar 16 14:50:35.216637 2024] [mpm_winnt:notice] [pid 8800:tid 340] AH00418: Parent: Created child process 5952
PHP Warning:  PHP Startup: Unable to load dynamic library 'bz2' (tried: C:\\php\\ext\\bz2 (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_bz2.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ldap' (tried: C:\\php\\ext\\ldap (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_ldap.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: C:\\php\\ext\\curl (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_curl.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'intl' (tried: C:\\php\\ext\\intl (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_intl.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'imap' (tried: C:\\php\\ext\\imap (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_imap.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring' (tried: C:\\php\\ext\\mbstring (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_mbstring.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'exif' (tried: C:\\php\\ext\\exif (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_exif.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: C:\\php\\ext\\mysqli (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_mysqli.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'openssl' (tried: C:\\php\\ext\\openssl (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_openssl.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: C:\\php\\ext\\pdo_mysql (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82), C:\\php\\ext\\php_pdo_mysql.dll (\xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82)) in Unknown on line 0
[Sat Mar 16 14:50:35.463834 2024] [mpm_winnt:notice] [pid 5952:tid 380] AH00354: Child: Starting 64 worker threads.

第一行是 Apache 的启动信息。它指示 Apache 在哪个进程 ID 下以及使用了哪个命令行启动。

第二行是Apache 父进程创建了一个子进程,子进程的进程 ID 是 5952。

后面的就是一系列的报错信息了,每个警告都指示 PHP 无法加载特定的动态链接库(dll 文件),并尝试了两种路径,但未找到对应的模块。一种是尝试在 C:\\php\\ext\\ 目录下找到对应的模块,另一种是尝试在 C:\\php\\ext\\ 目录下加载 php_ 开头的同名 DLL 文件。

例如,对于警告 Unable to load dynamic library 'bz2',系统首先尝试在 C:\\php\\ext\\ 目录下找到名为 bz2 的 DLL 文件,然后尝试加载名为 php_bz2.dll 的 DLL 文件。但是在这两种情况下,系统都未能找到正确的模块,导致加载失败。

解决办法

取消注释,并且填写实际路径

配置文件中说的很明白了,在windows 上的配置路径,并且我已经修改了内容,但是忘记去掉注释了。修改后正确的配置内容:


这段配置指定了 PHP 加载动态链接库(模块)的目录,即 extension_dir。在 Windows 系统中,该目录设置为 D:/My_WebSite/System/php-8.3.4-Win32-vs16-x64/ext,因为我的php的完整路径即是这样的。这意味着 PHP 将在这个目录下查找并加载所有的动态链接库文件。

完成后,重启apache服务。

修复验证

再次刷新浏览器,安装界面也顺利出现了。

发表评论

Index