我已经将 php 添加为 Apache 2.2.11 的模块:
LoadModule php5_module "c:/php/php5apache2_2.dll"
并且还添加了
AddType application/x-httpd-php .php
在 PHP.ini 中,我的扩展目录设置为:extension_dir = "C:\php\ext"
是的,目录是正确的,所有文件都存在。
但是当我启动 apache 时,我得到了这些错误:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pdo_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0
[Sun May 17 03:46:01 2009] [notice] Apache/2.2.11 (Win32) PHP/5.2.9-2 configured -- resuming normal operations
[Sun May 17 03:46:01 2009] [notice] Server built: Dec 10 2008 00:10:06
[Sun May 17 03:46:01 2009] [notice] Parent: Created child process 4652
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pdo_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0
[Sun May 17 03:46:01 2009] [notice] Child 4652: Child process is running
[Sun May 17 03:46:01 2009] [notice] Child 4652: Acquired the start mutex.
[Sun May 17 03:46:01 2009] [notice] Child 4652: Starting 64 worker threads.
[Sun May 17 03:46:01 2009] [notice] Child 4652: Starting thread to listen on port 80.
所以我可能在这里忘记了一些简单的事情,有人可以告诉我我忘记了什么吗?
最佳答案
为了向 PHP 添加 MySQL 和 PostgreSQL 支持,您不仅需要 PHP 扩展的 DLL。您还需要 MySQL 和 PostgreSQL native 库。 PHP 扩展的 DLL 可能找不到它们所依赖的某些 DLL,因此它们无法启动。
确保安装了 MySQL 和 PostgreSQL 客户端,并将它们的 DLL 放到某个可定位的位置。
即示例:
- php_mysql.dll 依赖于 libmysql.dll
因此,请确保 PHP 能够找到 libmysql.dll(我相信它随 Windows PHP 的二进制分发版一起提供。虽然不确定)。
关于PHP 扩展不会在 Apache 启动时加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/873734/