PHP 扩展不会在 Apache 启动时加载

标签 php windows apache

我已经将 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/

相关文章:

ruby-on-rails - 带有 RVM、Phusion Passenger、Apache 和 Nginx 的 Ubuntu 服务器

php - 在使用 6 个连接表进行选择查询期间检索到错误的 ID

java - 无法使用java运行命令提示符

c++ - DLL 中全局变量的使用限制(适用于 Windows)

apache - Socket.io 与 apache

apache - 网站显示 "It Works!"页面,而不是虚拟主机配置中指定的内容

php - PHP 中的正则表达式帮助(8 个十六进制字符后跟一个下划线)

php - 某游戏网站的Mysql搜索表优化

php - 如何在 Laravel 中建立 belongsTo() 关系?

c++ - 确定注册表项是否包含注册表值或子项的最佳方法是什么?