Windows 8 上的 Apache/PHP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13432192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache/PHP on Windows 8
提问by Simon Roberts
I'm having trouble with Apache/PHP on Windows 8. I have previously been using them on XP (along with MySQL) with no problems. I never used Windows 7.
我在 Windows 8 上使用 Apache/PHP 时遇到问题。我以前一直在 XP(以及 MySQL)上使用它们,没有任何问题。我从未使用过 Windows 7。
Apache installs without issues. Everything works OK, including all my virtual servers. PHP installs OK, the installation puts entries into httpd.conf without giving errors. However, when I try to load Apache after installing PHP, Apache won't load.
Apache 安装没有问题。一切正常,包括我所有的虚拟服务器。PHP 安装正常,安装将条目放入 httpd.conf 中而不会出错。但是,当我在安装 PHP 后尝试加载 Apache 时,Apache 不会加载。
I'm confused by the error that Apache returns when the PHP entries are included in httpd.conf:
当 PHP 条目包含在 httpd.conf 中时,Apache 返回的错误让我感到困惑:
Syntax error on line 1029 of C:/Program Files/Apache Group/Apache2/conf/httpd.conf:
Cannot load C:/Program Files/PHP/php5apache2_2.dll into server: The specified module could not be found.
The lines are:
这些行是:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:\Program Files\PHP\"
LoadModule php5_module "C:\Program Files\PHP\php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
(line 1029 is the LoadModule line). That location for the dll is definitely correct. The syntax of the line is as inserted by PHP. I have compared the syntax to previous versions of httpd.conf that I have and it appears correct. I think the syntax error is a red herring.
(第 1029 行是 LoadModule 行)。dll 的那个位置绝对是正确的。该行的语法与 PHP 插入的一样。我已经将语法与我拥有的 httpd.conf 的以前版本进行了比较,它看起来是正确的。我认为语法错误是一个红鲱鱼。
I have tried:
我试过了:
- Switching backslashes to slashes in the dll location.
- Adding PHP to the path.
- Installing Apache and PHP in both sequences.
- Checking the permissions to the PHP folder and the individual files to ensure that SYSTEM has read/execute.
- 在 dll 位置将反斜杠切换为斜杠。
- 将 PHP 添加到路径中。
- 在两个序列中安装 Apache 和 PHP。
- 检查 PHP 文件夹和各个文件的权限以确保 SYSTEM 已读取/执行。
Comment out the PHP lines and Apache loads fine. If I comment out the LoadModule line and and just leave the PHPIniDir line, it still fails. Apache seems to be behaving as though it can't see the PHP directory, but I can't work out why.
注释掉 PHP 行,Apache 加载正常。如果我注释掉 LoadModule 行并只保留 PHPIniDir 行,它仍然会失败。Apache 似乎表现得好像看不到 PHP 目录,但我不知道为什么。
There is nothing on the Windows event log. Latest versions of PHP and Apache. I'm at a bit of a loss what to try next. Any suggestions please?
Windows 事件日志中没有任何内容。最新版本的 PHP 和 Apache。我有点不知所措接下来要尝试什么。请问有什么建议吗?
回答by Davo
Download and follow instructions from this link: http://www.apachelounge.com/download/
从此链接下载并按照说明进行操作:http: //www.apachelounge.com/download/
The latest download (2.4) works on Windows 8 and Server 2012.
最新下载 (2.4) 适用于 Windows 8 和 Server 2012。
I downloaded and tested with the following on Windows 8: Each zip has a readme.txt or install.txt with instructions.
我在 Windows 8 上下载并测试了以下内容:每个 zip 都有一个 readme.txt 或 install.txt 和说明。
Apache 2.4 http://www.apachelounge.com/download/win32/binaries/httpd-2.4.3-win32.zip
PHP 5.4.8 http://windows.php.net/downloads/releases/php-5.4.8-Win32-VC9-x86.zip
- PHP 5.4.8 handler for Apache http://www.apachelounge.com/download/win32/modules-2.4/php5apache2_4.dll-php-5.4-win32.zip
Apache 2.4 http://www.apachelounge.com/download/win32/binaries/httpd-2.4.3-win32.zip
PHP 5.4.8 http://windows.php.net/downloads/releases/php-5.4.8-Win32-VC9-x86.zip
- Apache 的 PHP 5.4.8 处理程序 http://www.apachelounge.com/download/win32/modules-2.4/php5apache2_4.dll-php-5.4-win32.zip
My httpd.conf lines that were added/modified were:
我添加/修改的 httpd.conf 行是:
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module "C:/Apache24/php-5.4.8/php5apache2_4.dll"
LoadFile "C:/Apache24/php-5.4.8/php5ts.dll"
PHPIniDir "C:/Apache24/php-5.4.8"
<IfModule php5_module>
<Location />
AddType text/html .php
AddHandler application/x-httpd-php .php
#AddHandler application/x-httpd-php-source .phps
</Location>
</IfModule>
回答by elanoism
Its mentioned in the Readme.txt file packed with the dll's at ApacheLounge, but not anywhere else on the download page or in the filename (as all other versions):
它在 ApacheLounge 与 dll 打包在一起的 Readme.txt 文件中提到,但在下载页面或文件名中的其他任何地方都没有提到(与所有其他版本一样):
"Runs with PHP 5.4 Thread Safe (TS), and only with Apache 2.4 Win32 VC9 or VC10"
“与 PHP 5.4 线程安全 (TS) 一起运行,并且仅与 Apache 2.4 Win32 VC9 或 VC10 一起运行”
The dlls are only for the TS version, so if you've downloaded the other one, you are basically screwed. TS php binaries fixed it for me.
这些 dll 仅适用于 TS 版本,因此如果您下载了另一个,那么您基本上就完蛋了。TS php 二进制文件为我修复了它。
GL.
GL。
回答by Milan
I ran into the similar issue when reinstalling Apache and PHP on Win 8 (I am more Linux user though). And similar to the original post, no matter what I tried to do in httpd.conf and php.ini Apache simply either did not start or did not see the PHP. After spending unreasonable amount of time, I decided to download the PHP 5.3 (5.3.27)-VC9 x86 Thread Safe (2013-Jul-10 21:56:58) Installer [45.86MB]instead of the non-tread safe version which I have been using before. There is a difference in the .msi installers. The one for the thread-safe version actually contains the required files and if you follow the installer prompts it will actually asks you if the php installation should be "linked" to Apache server. Then you just provide the hhtpd.conf directory and all works fine. Thats my 2c on this :)
在 Win 8 上重新安装 Apache 和 PHP 时,我遇到了类似的问题(不过我更喜欢 Linux 用户)。和原来的帖子类似,无论我在 httpd.conf 和 php.ini 中尝试做什么,Apache 要么没有启动,要么没有看到 PHP。在花费了不合理的时间后,我决定下载PHP 5.3 (5.3.27)-VC9 x86 Thread Safe (2013-Jul-10 21:56:58) Installer [45.86MB]而不是非线程安全版本我以前一直在用。.msi 安装程序有所不同。线程安全版本实际上包含所需的文件,如果您按照安装程序提示进行操作,它实际上会询问您是否应将 php 安装“链接”到 Apache 服务器。然后您只需提供 hhtpd.conf 目录,一切正常。这就是我的 2c :)
回答by tonino.j
Presuming this is your development, not deployment environment, why don't you just download xamppfrom apache friends? It should come preconfigured, and you will deploy in other setup anyway.
假设这是你的开发环境,而不是部署环境,你为什么不直接从apache 朋友那里下载xampp呢?它应该是预先配置的,无论如何您都将在其他设置中进行部署。
回答by protogenoff
I think the problem is in the blank "Program Files".
我认为问题出在空白的“程序文件”中。

