无法将c:/php/php5apache2_4.dll加载到服务器中:找不到指定的模块 [英] Cannot load c:/php/php5apache2_4.dll into server: The specified module could not be found

查看:382
本文介绍了无法将c:/php/php5apache2_4.dll加载到服务器中:找不到指定的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试将PHP 5.6.30与Apache 2.4一起使用时,似乎存在一个众所周知的问题(除了使用Docker外),但是似乎没有解决该问题的真正解决方案.我收到以下错误:

When trying to use PHP 5.6.30 with Apache 2.4 there seems to be a somewhat well-known issue (outside of using Docker) but there does not seem to be any real solution for fixing the issue. I am getting the following error:

httpd.exe:C:/Apache24/conf/httpd.conf的第534行出现语法错误:无法将c:/php/php5apache2_4.dll加载到服务器中:找不到指定的模块.

httpd.exe: Syntax error on line 534 of C:/Apache24/conf/httpd.conf: Cannot load c:/php/php5apache2_4.dll into server: The specified module could not be found.

检查C:\ php目录(在Docker容器内部),我发现DLL显然在那里

Examining the directory of C:\php (inside the Docker container) I see the DLL is clearly there

03/09/2017  04:34 PM    <DIR>          .
03/09/2017  04:34 PM    <DIR>          ..
01/18/2017  08:12 PM            69,632 deplister.exe
03/09/2017  04:34 PM    <DIR>          dev
03/09/2017  04:34 PM    <DIR>          ext
03/09/2017  04:34 PM    <DIR>          extras
01/18/2017  08:12 PM         1,290,752 glib-2.dll
01/18/2017  08:12 PM            16,384 gmodule-2.dll
01/18/2017  08:12 PM        25,672,192 icudt57.dll
01/18/2017  08:12 PM         2,065,920 icuin57.dll
01/18/2017  08:12 PM            51,200 icuio57.dll
01/18/2017  08:12 PM           257,536 icule57.dll
01/18/2017  08:12 PM            50,176 iculx57.dll
01/18/2017  08:12 PM            63,488 icutest57.dll
01/18/2017  08:12 PM           196,096 icutu57.dll
01/18/2017  08:12 PM         1,456,128 icuuc57.dll
01/18/2017  08:12 PM            79,408 install.txt
03/09/2017  04:34 PM    <DIR>          lib
01/18/2017  08:12 PM         2,244,096 libeay32.dll
01/18/2017  08:12 PM            46,592 libenchant.dll
01/18/2017  08:12 PM           185,344 libpq.dll
01/18/2017  08:12 PM           237,056 libsasl.dll
01/18/2017  08:12 PM           213,504 libssh2.dll
01/18/2017  08:12 PM             3,286 license.txt
01/18/2017  08:12 PM           557,659 news.txt
01/18/2017  08:12 PM                43 phar.phar.bat
01/18/2017  08:12 PM            53,242 pharcommand.phar
01/18/2017  08:12 PM            59,392 php-cgi.exe
01/18/2017  08:12 PM            32,256 php-win.exe
01/18/2017  08:12 PM            79,872 php.exe
01/18/2017  08:12 PM             2,523 php.gif
01/18/2017  08:12 PM            75,684 php.ini-development
01/18/2017  08:12 PM            75,715 php.ini-production
01/18/2017  08:12 PM            32,768 php5apache2_4.dll <--- look right here
01/18/2017  08:12 PM           846,630 php5embed.lib
01/18/2017  08:12 PM           168,960 php5phpdbg.dll
01/18/2017  08:12 PM         8,343,040 php5ts.dll
01/18/2017  08:12 PM           181,760 phpdbg.exe
01/18/2017  08:12 PM            21,360 readme-redist-bins.txt
01/18/2017  08:12 PM             3,634 snapshot.txt
01/18/2017  08:12 PM           353,792 ssleay32.dll
              35 File(s)     45,087,120 bytes

answer 讨论了确保使用相同的位版本(我使用的是64位),并还要确保这些版本是线程安全的.在这里,在我的Dockerfile中,您可以看到指向Apache和PHP的64位线程安全版本的链接:

This answer talks about making sure to use the same bit version (I am using 64 bit) and to also make sure the versions are thread safe, which they are. Here, in my Dockerfile, you can see the links to the 64 bit thread-safe versions of Apache and PHP:

FROM microsoft/windowsservercore

RUN powershell -Command \
    $ErrorActionPreference = 'Stop'; \
    Invoke-WebRequest -Method Get -Uri https://www.apachelounge.com/download/VC11/binaries/httpd-2.4.25-win64-VC11.zip -OutFile c:\apache.zip ; \
    Expand-Archive -Path c:\apache.zip -DestinationPath c:\ ; \
    Remove-Item c:\apache.zip -Force

RUN powershell -Command \
    $ErrorActionPreference = 'Stop'; \
    Invoke-WebRequest -Method Get -Uri "http://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe" -OutFile c:\vcredist_x64.exe ; \
    start-Process c:\vcredist_x64.exe -ArgumentList '/quiet' -Wait ; \
    Remove-Item c:\vcredist_x64.exe -Force

RUN powershell -Command \
    $ErrorActionPreference = 'Stop'; \
    Invoke-WebRequest -Method Get -Uri http://windows.php.net/downloads/releases/php-5.6.30-Win32-VC11-x64.zip -OutFile c:\php.zip ; \
    Expand-Archive -Path c:\php.zip -DestinationPath c:\php ; \
    Remove-Item c:\php.zip -Force

RUN powershell -Command \
    $ErrorActionPreference = 'Stop'; \
    Remove-Item c:\Apache24\conf\httpd.conf ; \
    new-item -Type Directory c:\www -Force ; \
    Add-Content -Value "'<?php phpinfo() ?>'" -Path c:\www\index.php

ADD httpd.conf /apache24/conf

WORKDIR /Apache24/bin

CMD /Apache24/bin/httpd.exe -w

请注意,Visual Studio编译器适用于2015年.我真的需要为使用编译器打平竞争环境吗?

Note the Visual Studio compiler is for 2015. Do I really need to level the playing field for using the compiler?

最后,httpd.conf中的以下各行(错误中提到的 第534行是从LoadModule 开始的行)是导致启动时在容器的Docker日志中显示的错误.我现在将它们注释掉,这样我就可以使Apache作为独立版本启动(允许我检查容器内部发生了什么).

Finally, the following lines in the httpd.conf (line 534, mentioned in the error, is the line starting with LoadModule)are what is causing the error to show in the Docker logs for the container when started. I have them commented out at the moment so I could get Apache to start as a stand-alone (allowing me to examine what is going on inside of the container).

# configure the path to php.ini
# PHPIniDir "C:/php"
# LoadModule php5_module "c:/php/php5apache2_4.dll"
# AddHandler application/x-httpd-php .php

我计划在容器中部署一些现有的PHP代码,并且不希望升级到PHP7(这将产生更多工作来修复某些代码无法在PHP7上运行的问题).除了升级到PHP 7外,还有其他方法可以解决该问题吗?

I plan to deploy some existing PHP code in the container and do not want to upgrade to PHP7 (which will create more work to fix some things with code which will fail on PHP7). Outside of upgrading to PHP 7 is there any other way to fix the issue?

推荐答案

您将需要安装VC Redistributable的早期版本,因为更高的版本无法覆盖早期的版本.用来编译它的版本应在您从其下载的镜像上指出. PHP官方网站上的 Windows下载页面表示使用了2014,但您可能对2012也很幸运

You will need to install prior versions of the VC Redistributable since later versions do not cover earlier ones. The version used to compile it should be indicated on the mirror you downloaded it from. The Windows download page on the official PHP site indicates 2014 was used but you may have luck with 2012 as well.

您还应该这样设置配置:

You should also set up your configuration as such:

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

<IfModule php5_module>
    # configure the path to php.ini
    PHPIniDir "C:/php"
    AddHandler application/x-httpd-php .php
</IfModule>

这篇关于无法将c:/php/php5apache2_4.dll加载到服务器中:找不到指定的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆