apache启动服务报错ServerRoot must be a valid directory

  1. 【现象】

    D:apacheApache24in>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

    Apache报ServerRoot must be a valid directory
  2. 【原因】

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

  3. 【解决步骤一】

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

    本文为:D:apacheApache24confhttpd.conf

    Apache报ServerRoot must be a valid directory
  4. 【解决步骤二】

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

    Apache报ServerRoot must be a valid directory
  5. 【解决步骤三】

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

    D:apacheApache24in>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:apacheApache24in>httpd -v

    Apache报ServerRoot must be a valid directory
  6. 【解决步骤四】

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

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

    D:apacheApache24in>net start Apache2.4

    Apache2.4 服务正在启动 ..

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

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

    Apache报ServerRoot must be a valid directory
    Apache报ServerRoot must be a valid directory
    如果修改完路径还是不能启动,则需要修改conf文件夹下的httpd.conf文件,把里面的端口80改成其它没有被占用的端口
原文地址:https://www.cnblogs.com/qianzf/p/14373000.html