Apache报ServerRoot must be a valid directory

【现象】:

D:\apache\Apache24\bin>httpd -k install

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 40 of D:/apache/Apache24/conf/httpd.conf: ServerRoot must be a valid directory

【原因】:

httpd.conf里面配置的ServerRoot路径跟实际路径不一致,导致路径无效。

【解决步骤一】:

打开Apache2.4.16解压文件下的bin文件里面的httpd.conf

本文为:D:\apache\Apache24\conf\httpd.conf

 

【解决步骤二】:

打开httpd.conf后,搜索Define SRVROOT(只有一处),将其后面的双引号里面的路径改为Apache的实际解压路径后保存即可,本文为D:\apache\Apache24

 

【解决步骤三】:

运行CMD,cd到apache\Apache24\bin执行httpd -k install,不再报错ServerRoot must be a valid directory,成功安装apache服务。

D:\apache\Apache24\bin>httpd -k install

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.

D:\apache\Apache24\bin>httpd -v

【解决步骤四】:

启动apache服务并且测试apache服务

1、运行cmd后执行net start Apache2.4;

D:\apache\Apache24\bin>net start Apache2.4

Apache2.4 服务正在启动 ..

Apache2.4 服务已经启动成功。

2、浏览器输入:http://localhost/

 

打赏分享者

          如果这个分享对您提供了帮助,那就打赏我吧,有钱捧个钱场(支持支付宝和微信捐助),没钱捧个人场,有了大家的支持,我们会更有动力,会做的更好的,谢谢各位。

猜你喜欢

转载自itdatacenter.iteye.com/blog/2376102