想在本地安装Apache HTTP Server,先找到官网 https://httpd.apache.org/。
一通搜索之后没有发现安装包。静下心来仔细看说明,发现官网只提供源代码,不提供Windows的可执行文件。只能去第三方网站下载。
The Apache HTTP Server Project itself does not provide binary releases of software, only source code. Individual committers may provide binary packages as a convenience, but it is not a release deliverable.
If you cannot compile the Apache HTTP Server yourself, you can obtain a binary package from numerous binary distributions available on the Internet.
Popular options for deploying Apache httpd, and, optionally, PHP and MySQL, on Microsoft Windows, include:
・ApacheHaus
・Apache Lounge
・BitNami WAMP Stack
・WampServer
・XAMPP
从上面的第一个URL进去,下载Apache的第三方编译文件。
httpd-2.4.34-o110h-x64-vc14.zip
解压到本地环境。
用cmd进入bin文件夹,执行以下命令将Apache加入Windows的Servers。
httpd -k install
运行错误。没有权限。
用管理员权限运行cmd,再次执行安装命令,再次发生错误。
Installing the ‘Apache2.4’ service
The ‘Apache2.4’ service is successfully installed.
Testing httpd.conf…
Errors reported here must be corrected before the service can be started.
httpd:Syntax error on line 39 of D:/XXXX/httpd.conf: ServerRoot must be a valid directory
看来配置文件需要修改。
打开 httpd.conf文件。修改以下配置
38 Define SRVROOT “/Apache24”
39 ServerRoot “${SRVROOT}”扫描二维码关注公众号,回复: 5504093 查看本文章
修改为
38 Define SRVROOT “D:/XXXX/Apache24”
39 ServerRoot “${SRVROOT}”
从Server中启动仍然失败,从Event Viewer中查看失败log,有以下三种信息。
The Apache service named reported the following error:
(OS 10048)通常、各ソケット アドレスに対してプロトコル、ネットワーク アドレス、またはポートのどれか 1 つのみを使用できます。 : AH00072: make_sock: could not bind to address [::]:443
The Apache service named reported the following error:
AH00451: no listening sockets available, shutting down
The Apache service named reported the following error:
AH00015: Unable to open logs
在cmd用以下命令找到占用443端口的程序的PID是13812,从任务管理器找到13812程序是 VMWare。不想动虚拟机的设置。于是返回继续找httpd的配置文件
netstat –ano
原来是ssl的配置文件中用到了443端口。
conf\extra\httpd-ssl.conf
Listen 443
改为444端口后再次尝试启动service。仍然报错…….
有漏网之鱼。httpd-ahssl.conf 文件中也有443端口设置。修改之后再次尝试启动service。再次失败。。。。。
尝试删除服务重新安装
httpd -k uninstall
httpd -k install
仍然失败。。。。。睡觉。明天再试。
20180914更新
conf\extra\httpd-ssl.conf 文件中有漏改的部分,修改之后成功启动server。搞定。
想来,其实ssl功能暂时用不上,直接从配置文件中去掉ssl的conf引用也能搞定。