简体   繁体   English

Apache启动时不会加载PHP扩展

[英]PHP extensions won't load on Apache startup

I've added php as a module for Apache 2.2.11: 我已经添加了php作为Apache 2.2.11的模块:

LoadModule php5_module "c:/php/php5apache2_2.dll"

And also added 并补充说

AddType application/x-httpd-php .php

And in PHP.ini, my extension dir is set to: extension_dir = "C:\\php\\ext" 在PHP.ini中,我的扩展名dir设置为: extension_dir = "C:\\php\\ext"

And yes , the directories are correct and all files do exist. 是的 ,目录是正确的,所有文件都存在。

But when I start apache, I get these errors: 但是当我启动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警告:PHP启动:无法加载动态库'C:\\ php \\ ext \\ php_mysql.dll' - 找不到指定的模块。\\ r \\ n在第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警告:PHP启动:无法加载动态库'C:\\ php \\ ext \\ php_pdo_pgsql.dll' - 找不到指定的模块。\\ r \\ n在第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 PHP警告:PHP启动:无法加载动态库'C:\\ php \\ ext \\ php_pgsql.dll' - 找不到指定的模块。\\ r \\ n在第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] [通知] Apache / 2.2.11(Win32)PHP / 5.2.9-2配置 - 恢复正常操作
[Sun May 17 03:46:01 2009] [notice] Server built: Dec 10 2008 00:10:06 [Sun May 17 03:46:01 2009] [通知]服务器内置:2008年12月10日00:10:06
[Sun May 17 03:46:01 2009] [notice] Parent: Created child process 4652 [Sun May 17 03:46:01 2009] [通知]家长:创建子进程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警告:PHP启动:无法加载动态库'C:\\ php \\ ext \\ php_mysql.dll' - 找不到指定的模块。\\ r \\ n在第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警告:PHP启动:无法加载动态库'C:\\ php \\ ext \\ php_pdo_pgsql.dll' - 找不到指定的模块。\\ r \\ n在第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 PHP警告:PHP启动:无法加载动态库'C:\\ php \\ ext \\ php_pgsql.dll' - 找不到指定的模块。\\ r \\ n在第0行的未知中

[Sun May 17 03:46:01 2009] [notice] Child 4652: Child process is running [Sun May 17 03:46:01 2009] [通知]儿童4652:儿童过程正在运行
[Sun May 17 03:46:01 2009] [notice] Child 4652: Acquired the start mutex. [Sun May 17 03:46:01 2009] [notice] Child 4652:获得了启动互斥。
[Sun May 17 03:46:01 2009] [notice] Child 4652: Starting 64 worker threads. [Sun May 17 03:46:01 2009] [notice] Child 4652:启动64个工作线程。
[Sun May 17 03:46:01 2009] [notice] Child 4652: Starting thread to listen on port 80. [Sun May 17 03:46:01 2009] [notice] Child 4652:启动线程侦听端口80。

So I'm probably forgetting something simple here, can someone tell me what I'm forgetting? 所以我可能在这里忘记了一些简单的事情,有人能告诉我我忘了什么吗?

Not only you need PHP extension's DLLs in order to add MySQL and PostgreSQL support to PHP. 您不仅需要PHP扩展的DLL来为PHP添加MySQL和PostgreSQL支持。 You also need MySQL and PostgreSQL native libraries. 您还需要MySQL和PostgreSQL本机库。 PHP extension's DLLs are probably not finding some DLL they depend on, so they can't start. PHP扩展的DLL可能找不到它们依赖的DLL,因此它们无法启动。

Make sure you have MySQL and PostgreSQL client installed, and their DLLs into some locatable place. 确保已安装MySQL和PostgreSQL客户端,并将其DLL放入某些可定位的位置。

IE example: IE示例:

  • php_mysql.dll depends on libmysql.dll php_mysql.dll依赖于libmysql.dll

So, make sure PHP is able to find libmysql.dll (I believe this one comes with the binary distribution of Windows PHP. Not sure though). 所以,确保PHP能够找到libmysql.dll(我相信这个附带了Windows PHP的二进制发行版。但不确定)。

To add to Pablo Santa Cruz's advice. 添加到Pablo Santa Cruz的建议中。 On windows you can include the required libraries in the PATH environment. 在Windows上,您可以在PATH环境中包含所需的库。 (No necessarily copy to Windows folder). (不一定要复制到Windows文件夹)。 When loading libraries widows looks in PATH directories as well. 加载库时,widows也会在PATH目录中查找。

If you use standard Win32 binary distribution from php.net for PHP5.2, then the package should contain all the dependencies in the root of the packages. 如果您使用php.net的PHP5.2标准Win32二进制分发版,则该软件包应该包含软件包根目录中的所有依赖项。 So, if you have installed the PHP5.2 into C:\\php , add this directory to the PATH envar. 因此,如果您已将PHP5.2安装到C:\\php ,请将此目录添加到PATH envar中。 Restart the Apache and I'd expect extensions to load properly. 重启Apache,我希望扩展能够正确加载。

I had the same problem. 我有同样的问题。 I was getting one of those annoying windows popup errors everytime I tried to log in to phpmyadmin. 我每次尝试登录phpmyadmin时都会收到其中一个令人讨厌的Windows弹出错误。 I typed in the username and password and then would throw the error. 我键入了用户名和密码,然后抛出错误。

What solved it for me, was also copying the libmysql.dl to the apache bin directory. 为我解决了什么,也是将libmysql.dl复制到apache bin目录。 The strange thing is apparantly the extensions where included correctly but still I needed to do this. 奇怪的是,正确包含的扩展名仍然是我需要这样做的。

I tried several of these solutions and one or more of them worked... Rebooting is the key here. 我尝试了其中一些解决方案,其中一个或多个解决了......重新启动是关键。 I did not reboot in between these changes, but after I rebooted it was working: 我没有在这些更改之间重新启动,但在我重新启动后它正在工作:

  • add postgres DLL to apache lib dir 将postgres DLL添加到apache lib目录
  • add postgres path to system PATH 将postgres路径添加到系统PATH
  • add postgres DLL to system32 将postgres DLL添加到system32

I believe just the PATH would have worked but no time for cleanliness here so there you go. 我相信只有PATH会有效,但没有时间在这里清洁,所以你去。

Those extensions depend on native libraries which are provided by the MySQL and PostgreSQL binary distributions. 这些扩展依赖于由MySQL和PostgreSQL二进制发行版提供的本机库。 Install them and put the libs in apache's bin folder for example. 例如,安装它们并将lib放在apache的bin文件夹中。 Those are LIBMYSQL.DLL and LIBPQ.DLL respectively. LIBPQ.DLL分别是LIBMYSQL.DLLLIBPQ.DLL

I usually do that instead of polluting Windows/System32 folder with them, because on my system only the apache/php is the client of those databases and also it makes my apache/php setup more portable. 我通常这样做而不是用它们污染Windows/System32文件夹,因为在我的系统上只有apache / php是这些数据库的客户端,而且它使我的apache / php设置更加便携。

I had a problem with a specific version of PHP on Windows. 我在Windows上遇到了特定版本的PHP问题。 The problem was libmysql. 问题是libmysql。 I found a posted bug on the php.net site from someone having the same problem. 我在php.net网站上发现了一个有相同问题的人发布的错误。

I used the previous php release and libmysql worked. 我使用了以前的php发布和libmysql工作。 Check out the notes on the php distribution you are using. 查看您正在使用的php发行版的注释。 I think that after a specific version they mention a new policy regarding libmysql. 我认为在特定版本之后,他们提到了一个关于libmysql的新政策。

From what you mention php is unable to find the extensions. 从你提到的PHP无法找到扩展名。 Make sure you have set the path on php.ini that specifies where the extensions are located, that the extensions exist and that the folder can be accessed (read-permissions). 确保已在php.ini上设置路径,该路径指定扩展所在的位置,扩展存在以及可以访问该文件夹(读取权限)。

If all fails try moving the extension to windows/system32 in an effort to find what might be the real problem. 如果全部失败,请尝试将扩展程序移动到windows / system32,以便找到可能存在的真正问题。

Regards, 问候,

In my experience, PHP on Windows is a major pain in the behind. 根据我的经验,Windows上的PHP是背后的主要痛苦。 I usually get it to work eventually, but there's always a lot of googling and trial-and-error involved - for me at least. 我通常最终会让它工作,但总是有很多谷歌搜索和试错,至少对我来说。

So I finally got sick and tired of it and simply installed Ubuntu Server in a VM and had it up and running within minutes. 所以我终于厌倦了它,只是在一台虚拟机中安装了Ubuntu Server,并在几分钟内启动并运行。 Whether this is an option for you or not I can't say, but if it is it will most definitely save you a lot of headaches in the long run. 这是否是你的选择,我不能说,但如果是这样,从长远来看,它绝对会给你带来很多麻烦。 Not to mention you can always move your VMs around, create snapshots and do all the other fancy stuff that VMs are good for. 更不用说你总是可以移动你的虚拟机,创建快照,并做所有其他虚拟的东西,虚拟机是有益的。

I'm also had same problem and solved by adding "PostgreSQL" bin path into System Environment variables 我也有同样的问题,并通过将“PostgreSQL”bin路径添加到系统环境变量中来解决

PATH: C:\\Program Files\\PostgreSQL\\8.4\\bin You can check in phpinfo() also. 路径:C:\\ Program Files \\ PostgreSQL \\ 8.4 \\ bin您也可以签入phpinfo()。

When I install PostgreSQL, setting into System Path missed. 当我安装PostgreSQL时,设置为系统路径错过了。 I manually added then restart the system. 我手动添加然后重启系统。

I had this problem too, and copied the pertinent (.dlls) to systen 32 and it still did not work for me. 我也有这个问题,并将相关的(.dll)复制到systen 32,它仍然不适合我。 I am running Windows 7 64bit. 我正在运行Windows 7 64位。 To get this to work for me I had to also copy the libmysql.dll to the ext directory. 为了让我能够工作,我还必须将libmysql.dll复制到ext目录。 The error message left the Apache log and the page loaded with a favorable response (conection established). 该错误消息使Apache日志和页面加载了有利的响应(建立了连接)。

the problem here is that apache has loaded PHP, but PHP was not able to load its extension (mysql, postgresql, ...). 这里的问题是apache已加载PHP,但PHP无法加载其扩展名(mysql,postgresql,...)。 I think you should enter path values in your php.ini file in unix format (do not use backslash characters as directory separator). 我认为你应该以unix格式在php.ini文件中输入路径值(不要使用反斜杠字符作为目录分隔符)。 so in your php.ini file change this: 所以在你的php.ini文件中改变这个:

extension_dir="C:/php/ext" 的extension_dir = “C:/ PHP / EXT”

I had the same problem and have tried copying libmySQL.dll to the apache bin folder and it solved the problem (I'm setting up PHP 5.2.5 x64). 我有同样的问题,并尝试将libmySQL.dll复制到apache bin文件夹,它解决了问题(我正在设置PHP 5.2.5 x64)。 Many thanks. 非常感谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM