[liunx apache配置]DocumentRoot does not exist解决方法

本文介绍了解决Apache服务器启动时出现DocumentRoot路径不存在错误的方法。通常此问题由SELinux引起,文中提供了两种解决方案:一是修改SELinux配置文件并重启服务器;二是通过命令临时禁用SELinux。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

重启Apache提示DocumentRoot does not exist,类似如下:
Stopping httpd: [ OK ]
Starting httpd: Warning: DocumentRoot [/var/www/html/test] does not exist

奇怪的是路径明明已经存在。查了下发现一般是由于启用了SELINUX导致的,解决方法为禁用SELINUX:
1.编辑selinux配置文件/etc/selinux/config
# This file controls the state of SELinux on the system.
# 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=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted – Only targeted network daemons are protected.
# strict – Full SELinux protection.
SELINUXTYPE=targeted
一般内容如上面所示,将SELINUX=enforcing改成SELINUX=disabled然后重启服务器即可。

2.如果不想重启服务器,直接执行
# setenforce 0
即可。

再重启Apache就正常了。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值