「Cannot load php5apache2_4.dll into server」問題的解決方法

下載了最新的PHP+Apache Httpd Server,版本號分別爲5.5.0和2.4.3,完成配置修改後,啓動Apache服務器,上報「Cannot load php5apache2_4.dll into server」錯誤。php

一、覺得是配置文件寫錯,仔細檢查後,確實沒有看出什麼問題。shell

二、覺得是採用了不匹配的線程安全版本,仔細檢查後,PHP和Apache均是線程安全的版本。apache

三、排除法,刪除httpd.conf中的這句話,Apache啓動成功。Windows上的PHP和Apache採用dll動態連接庫的方式配合,一種CGI方式,感受問題出在dll上。windows

LoadModule php5_module "D:\PHP\php5apache2_4.dll"

四、查找網上的一些帖子,各類分析較多,搞得我思路混亂。但我堅信問題必定不會是PHP和Apache兩個組織沒有相互測試配套關係,確定是本身哪裏理解錯了,決定登陸PHP官網,windows.php.net,找到下面一段話,人家說的很清楚:安全

Which version do I choose?

IIS
If you are using PHP with IIS you should use the Non-Thread Safe (NTS) versions of PHP.

Apache
Please use the Apache builds provided by Apache Lounge. They also provide VC11 builds of Apache for x86 and x64. We use their binaries to build the Apache SAPIs.

If you are using PHP with Apache 1 or Apache2 from apache.org (not recommended) you need to use the older VC6 versions of PHP compiled with the legacy Visual Studio 6 compiler. Do NOT use VC9+ versions of PHP with the apache.org binaries.

VC9 and VC11
More recent versions of PHP are built with VC9 or VC11 (Visual Studio 2008 and 2012 compiler respectively) and include improvements in performance and stability.

The VC9 builds require you to have the Visual C++ Redistributable for Visual Studio 2008 SP1 x86 or x64 installed.

查看系統的Visual Studio Distribute版本是2008,對應VC9,但我使用的是Visual Studio 2012編譯的PHP版本(VC11),動態鏈接於Apache中的dll,可能就會出現問題。從新下載了VC9版本的PHP,Apache Httpd Server啓動成功,問題解決!服務器


下載開源軟件時,要特別注意編譯環境的版本,仔細閱讀軟件的版本ReleaseNotes,每每能解決絕大多數問題。ide

相關文章
相關標籤/搜索