Apache报ServerRoot must be a valid directory

作者:暴躁小n | 创建时间: 2023-03-31
WIN7系统运行cmd后,通过httpd -k install安装Apache时报错 ServerRoot must be a valid directory的解决方法。...
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/

温馨提示

Apache解压路径最好不要用中文。
点击展开全文

更多推荐