免安装版apache注册window服务

来源:互联网 发布:360 云盘mac如何使用 编辑:程序博客网 时间:2024/06/09 15:33
安装apache:
从官网下载apache2.2.29发现是免安装版的。首先就需要对apache注册服务
把apache拷贝到一个目录下,打开cmd
执行
httpd.exe -k install -n apache2


D:\tools\Apache22\bin>httpd.exe -k install -n apache2
Installing the apache2 service
The apache2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
httpd.exe: Syntax error on line 35 of D:/tools/Apache22/conf/httpd.conf: ServerR
oot must be a valid directory


出现error,提示ServerRoot目录错误,修改为conf/httpd.conf文件中ServerRoot 为"D:\tools\Apache22",apache所在的目录


再次执行httpd.exe -k install -n apache2发现
D:\tools\Apache22\bin>httpd.exe -k install -n apache2
[Mon Apr 20 16:07:54 2015] [error] apache2: Service is already installed.

该服务已存在
说明已经安装上了,刚才是测试报错。
下面开始启动apache
D:\tools\Apache22\bin>net start apache2
apache2 服务正在启动 .
apache2 服务无法启动。

又出现报错,说明配置文件还有错误。免安装版真费劲!
查看log,没有记录日志。只能删掉window的服务,再次安装查看错误
删除服务命令:
D:\tools\Apache22\bin>sc delete apache2
[SC] DeleteService 成功

再次安装:
D:\tools\Apache22\bin>httpd.exe -k install -n apache2
Installing the apache2 service
The apache2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
Syntax error on line 179 of D:/tools/Apache22/conf/httpd.conf:
DocumentRoot must be a directory

提示DocumentRoot错误
修改为conf/httpd.conf文件中DocumentRoot为 "D:\tools\Apache22\htdocs"


检查一下conf文件中是否还有别的这样路径的错误,有就修改过来
再次启动发现还有错误,重新安装服务:
D:\tools\Apache22\bin>httpd.exe -k install -n apache2
Installing the apache2 service
The apache2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
Syntax error on line 110 of D:/tools/Apache22/conf/extra/httpd-ahssl.conf:
SSLCertificateFile: file 'D:/Apache22/conf/ssl/server.crt' does not exist or is
empty

是ssl验证错误,从目录结构看,也是路径的问题,不过我这里暂时不需要ssl,这个模块用不到,就先注释掉。重新启动
D:\tools\Apache22\bin>net start apache2
apache2 服务正在启动 .
apache2 服务已经启动成功。

服务启动成功!
打开浏览器访问http://127.0.0.1(默认端口80)

出现一个apache的页面或者It works!则安装成功!


附;apache官网免安装版apache2.2.29 64位(最讨厌在blog里面balabala说一大堆,最后想下载的时候毛都找不到)


0 0