Apache 不从 PHP 加载模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32767925/
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 doesn't load module from PHP
提问by Giancarlo Abel Giulian
I am following this portuguese article to configure Apache and PHP:
我正在关注这篇葡萄牙语文章来配置 Apache 和 PHP:
How Install And Configure The Development Environment in PHP - Part 2.
I already set up the php.iniand httpd.conffiles. Besides to php5apache2_4.dllis in the right directory, but when I restart the server show me the following error:
我已经设置了php.ini和httpd.conf文件。除了php5apache2_4.dll位于正确的目录中,但是当我重新启动服务器时显示以下错误:
httpd.exe: Syntax error on line 531 of D:/Apache24/conf/httpd.conf: Invalid LoadModule path \xe2\x80\xaa"D:/php-5.6.13/php5apache2_4.dll"
httpd.exe:D:/Apache24/conf/httpd.conf 的第 531 行的语法错误:无效的 LoadModule 路径 \xe2\x80\xaa"D:/php-5.6.13/php5apache2_4.dll"
Httpd.conf:
配置文件:
LoadModule php5_module ?"D:/php-5.6.13/php5apache2_4.dll"
AddType application/x-httpd-php .php
PHPIniDir "D:/php-5.6.13/"
EDIT
编辑
I changed the Httpd.conffile.
我更改了Httpd.conf文件。
LoadModule php5_module ?"../php-5.6.13/php5apache2_4.dll"
AddType application/x-httpd-php .php
PHPIniDir "../php-5.6.13/"
And now is returning me a new error:
现在给我返回一个新错误:
httpd.exe: Syntax error on line 531 of D:/Apache24/conf/httpd.conf: Cannot load ../php-5.6.13/php5apache2_4.dll into server: %1 n\xe3o \xe9 um aplicativo Win32 v\xe1lido.
httpd.exe:D:/Apache24/conf/httpd.conf 的第 531 行语法错误:无法将 ../php-5.6.13/php5apache2_4.dll 加载到服务器:%1 n\xe3o \xe9 um aplicativo Win32 v\ xe1lido。
In English language: Not a valid Win32 application.
英语:不是有效的 Win32 应用程序。
In console:
在控制台中:
php -version
PHP 5.6.13 (cli) (built: Sep 3 2015 15:14:40)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
httpd -version
Server version: Apache/2.4.16 (Win64)
Apache Lounge VC14 Server built: Jul 22 2015 13:24:19
回答by Burrito
I just had the same problem trying to configure php7, so for anyone else having trouble:
我在尝试配置 php7 时遇到了同样的问题,所以对于遇到问题的其他人:
There may be a few issues. Check that your versions of php and Apache are bit-compatible (both 64-bit x64
or both 32-bit x86
; note that when downloading 64-bit PHP from windows.php.net/download/, the zip file will be called php...Win32...x64
).
可能有几个问题。检查您的 php 和 Apache 版本是否位兼容(64 位x64
或 32 位x86
;请注意,从windows.php.net/download/下载 64 位 PHP 时,将调用 zip 文件php...Win32...x64
)。
Also check that they are both compiled with the same version of Visual Studio (e.g. VC14). This happened to be the problem here: www.apachelounge.com/viewtopic.php?t=6596
还要检查它们是否都是使用相同版本的 Visual Studio(例如 VC14)编译的。这恰好是这里的问题:www.apachelounge.com/viewtopic.php?t=6596
In my case, I had the problem paulsm4referred to about quotes. I copied and pasted the code from a website and noticed that when I ran httpd -k start
, my error was httpd: Syntax error on line 62 of C:/Apache24/conf/httpd.conf: Invalid LoadModule path \x93c:/php7/php7apache2_4.dll\x94
. The \x93
and \x94
are the CP1252 encodingsfor fancy open and end quotes. Eliminating these or replacing them with regular quotes fixed the problem and Apache ran smoothly with PHP after that.
就我而言,我遇到了paulsm4提到的有关引号的问题。我从一个网站复制并粘贴了代码,并注意到当我运行时httpd -k start
,我的错误是httpd: Syntax error on line 62 of C:/Apache24/conf/httpd.conf: Invalid LoadModule path \x93c:/php7/php7apache2_4.dll\x94
. 该\x93
和\x94
是CP1252编码花式开放和最终报价。消除这些或用常规引号替换它们解决了问题,之后 Apache 与 PHP 一起顺利运行。
Another problem someone else ran into was trying to configure Apache with NTS (non-thread-safe) PHP.
其他人遇到的另一个问题是尝试使用 NTS(非线程安全)PHP 配置 Apache。
php.net/manual/en/install.windows.apache2.phpThe PHP download website also makes this point.
php.net/manual/en/install.windows.apache2.phpPHP 下载网站也说明了这一点。
回答by Michael
Removing the double-quotes form the httpd_uwamp.conf
file worked for me on both UnWamp
and PHP
distributions. (No spaces are in any of my path names)
从httpd_uwamp.conf
文件中删除双引号对我UnWamp
和PHP
发行版都适用。(我的任何路径名中都没有空格)
For Example Change
例如更改
LoadModule "{PHPMODULENAME} {PHPPATH}/{PHPAPACHE2FILE}"
to LoadModule {PHPMODULENAME} {PHPPATH}/{PHPAPACHE2FILE}
LoadModule "{PHPMODULENAME} {PHPPATH}/{PHPAPACHE2FILE}"
到 LoadModule {PHPMODULENAME} {PHPPATH}/{PHPAPACHE2FILE}
Thanks to Giancarlo Abel Giulian for his post ;-)
感谢 Giancarlo Abel Giulian 的帖子;-)
回答by rwilson
I was having the same problem:
我遇到了同样的问题:
Invalid LoadModule path \xe2\x80\x9cC:/WAMP/php/php5apache2_4.dll\xe2\x80\x9d.
无效的 LoadModule 路径 \xe2\x80\x9cC:/WAMP/php/php5apache2_4.dll\xe2\x80\x9d。
Based on paulsm4 suggestion above, I deleted the quotes in the directive LoadModule php5_module and replaced with simple quotes:
基于上面的 paulsm4 建议,我删除了指令 LoadModule php5_module 中的引号并替换为简单的引号:
LoadModule php5_module "C:/WAMP/php/php5apache2_4.dll"
This solved it for me.
这为我解决了它。
回答by cquezel
I had a similar error du to a simple cut and paste error from an older httpd.conf file where I had
我有一个类似的错误,因为我有一个旧的 httpd.conf 文件的简单剪切和粘贴错误
LoadModule php5_module ...
instead of
代替
LoadModule php7_module ...
Hope this may help someone else Googling this error message.
希望这可以帮助其他人谷歌搜索此错误消息。
回答by cquezel
I had tough time to get rid of this error, eventually resolved after both ( Apache and PHP ) installed x86 version ( not 64 ).
我很难摆脱这个错误,最终在(Apache 和 PHP)安装了 x86 版本(不是 64)之后解决了。
Also avoided simple folder name i.e. Apache2.4 or php, instead using detailed name like php_7.1.21_vc14_x86_ts
and Apache_2.4.34_vc14_x86
to catch mismatch by looking at folder name itself instead of keep getting weird error.
还避免了简单的文件夹名称,即 Apache2.4 或 php,而是使用详细的名称,例如 php_7.1.21_vc14_x86_ts
,Apache_2.4.34_vc14_x86
通过查看文件夹名称本身来捕捉不匹配,而不是不断出现奇怪的错误。
回答by DeepakPixel
I can understand how does it feels to get that error. Well after hours of research what i found was just remove the double-quotes and you are good to go. There is no need to remove double quotes from all the three lines. Remove them from the line which is giving you error.
我能理解得到那个错误的感觉。经过数小时的研究,我发现只是删除双引号,您就可以开始了。不需要从所有三行中删除双引号。从给你错误的行中删除它们。
Before
前
PHPIniDir “C:/PHP”
AddHandler application/x-httpd-php .php
LoadModule php7_module "C:/PHP/php7apache2_4.dll"
After
后
PHPIniDir “C:/PHP”
AddHandler application/x-httpd-php .php
LoadModule php7_module C:/PHP/php7apache2_4.dll
It worked for me. I don't think the upper two lines will give you error until and unless you have installed the PHP in insanely wrong way.
它对我有用。我不认为上面的两行会给你错误,除非你以极其错误的方式安装了 PHP。
to test it (if you dont know)
测试它(如果你不知道)
open cmd (no need to open as administrator but you can)
navigate to the bin folder into c:/apache/bin (or whatever your folder is)
type httpd -t and it should show syntax OK if it is not so you need to work on the line which it says have got an error. All he best.
打开cmd(不需要以管理员身份打开,但你可以)
导航到 bin 文件夹进入 c:/apache/bin (或任何你的文件夹)
键入 httpd -t,如果不是,它应该显示语法 OK,所以你需要在它说有错误的那一行上工作。都是他最好的。
Pretty bad reply? i know as it is my first reply to any doubt.
回复很差?我知道,因为这是我对任何疑问的第一次答复。
回答by Solkom
You have to make sure that you are using compatible version PHP with apache. Such that if you are running apache 32 bit make sure you are using PHP 32 bit and the same applies for 64 BIT. For preliminary analysis do the following.
您必须确保使用与 apache 兼容的 PHP 版本。这样,如果您运行 apache 32 位,请确保您使用的是 PHP 32 位,这同样适用于 64 位。对于初步分析,请执行以下操作。
Open command prompt and navigate to your apache installation bin folder such as cd "C:/Apache24/bin"
Then run the following command to see if syntax is OK httpd.ex -t
打开命令提示符并导航到您的 apache 安装 bin 文件夹,例如 cd "C:/Apache24/bin"
然后运行以下命令查看语法是否正常 httpd.ex -t
The response will tell you if the mentioned dll php5apache2_4.dll is missing in your PHP location. if this is the case then you have to download the specific compatible PHP version with apache. otherwise it will tell you that syntax is ok.
响应将告诉您在您的 PHP 位置中是否缺少提到的 dll php5apache2_4.dll。如果是这种情况,那么您必须使用 apache 下载特定的兼容 PHP 版本。否则它会告诉你语法没问题。
for more information please visit this link
欲了解更多信息,请访问此链接
回答by Odkhuu Ts
Change
改变
LoadModule php7_module "c:/php/php7apache2_4.dll"
to??
到??
LoadModule php7_module /php/php7apache2_4.dll
and???
和???
PHPIniDir "c:/php"
to??
到??
PHPIniDir /php
Well done.
做得好。
回答by Abhi
Cannot load modules/php7apache2_4.dll into server: The specified module could not be found. This is a common problem while setting up apache and php environment into a local computer
无法将模块/php7apache2_4.dll 加载到服务器:找不到指定的模块。这是本地电脑设置apache和php环境时常见的问题
I also faced the same issue: The best way to approach the problem would be to install the same VC level for the apache server and the php and also make sure that the same VC++ is also installed in the computer.
我也遇到了同样的问题:解决这个问题的最好方法是为 apache 服务器和 php 安装相同的 VC 级别,并确保计算机中也安装了相同的 VC++。
For me I tried with VC14 for apache24 and php and also installed VC++ 2015 edition which happens to be VC14
对我来说,我尝试将 VC14 用于 apache24 和 php,并且还安装了 VC++ 2015 版,它恰好是 VC14
回答by Mike kenneth
In my case, it was due to the type of PHP7 downloaded: Non Thread Safe
Just download the Thread Safe
version and extract to C:\php7 (Default directory)
, then try starting Apache Service again.
就我而言,这是由于下载的 PHP7 类型:Non Thread Safe
只需下载Thread Safe
版本并解压缩到C:\php7 (Default directory)
,然后再次尝试启动 Apache 服务。
Hope this help!!!
希望这有帮助!!!