无法启动Apache(无法将目录更改为/ root)

尝试使用以下命令启动Apache时:

/etc/init.d/httpd start 

/var/log/httpd/error_log出现以下错误:

 Unable to change directory to /root 

任何人都知道这意味着什么?

它的SELinux。

因为你启用了它,你需要使用启动服务

 service httpd start 

编辑你的SELinuxconfiguration,并禁用它或将其设置为宽容:

nano / etc / sysconfig / selinux

 # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled 

一旦改变,那么你将能够启动httpd使用:

 /etc/init.d/httpd start 

如果您需要保持启用SELinux,那么只需使用服务脚本启动/停止/重新启动服务。

 # service httpd start/stop/restart 

ServerRoot显然没有设置(正确)。

如果未设置,则默认为$ HOME。

编辑httpd.conf并设置合适的ServerRoot(通常是/ etc / httpd或/ etc / apache2)。

如果你想在不禁用SELinux的情况下运行它,那么不要试图在/ root目录下运行http start / stop命令。

这是临时修复,但总是工作,只需切换到/ tmp(cd / tmp)并运行命令来启动apache(/etc/init.d/httpd start)