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

    Apache報ServerRoot must be a valid directory
  • 【原因】

    httpd.conf里面配置的ServerRoot路徑跟實際路徑不一致,導致路徑無效。

  • 【解決步驟一】

    打開Apache2.4.16解壓文件下的bin文件里面的httpd.conf

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

    Apache報ServerRoot must be a valid directory
  • 【解決步驟二】

    打開httpd.conf后,搜索Define SRVROOT(只有一處),將其后面的雙引號里面的路徑改為Apache的實際解壓路徑后保存即可,本文為D:\apache\Apache24

    Apache報ServerRoot must be a valid directory
  • 【解決步驟三】

    運行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報ServerRoot must be a valid directory
  • 【解決步驟四】

    啟動apache服務並且測試apache服務

    1、運行cmd后執行net start Apache2.4;

    D:\apache\Apache24\bin>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改成其它沒有被占用的端口

  • 免責聲明!

    本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



     
    粵ICP備18138465號   © 2018-2025 CODEPRJ.COM