"警告:DocumentRoot [/var/www/vhosts] 不存在",尽管我已经创建了 /var/www/vhosts?



我已经安装了 apache 并在 CentOS 6.4 上配置了我的虚拟主机。

但是当我重新启动 apache(使用此命令:sudo service httpd restart )时,它警告我"警告:DocumentRoot [/var/www/vhosts] 不存在"。我已经检查了目录/var/www/vhosts,它已经创建并且权限为 0777。我做错了什么?请帮忙...

->这是我的虚拟主机配置。

DocumentRoot /var/www/vhosts
ServerName trien.cba
ServerAlias trien.cba
ErrorLog /var/log/httpd/trien.cba.error.log
CustomLog /var/log/httpd/trien.cba.access.log common
AllowOverride All
Order allow,deny
Allow from all
Options -Indexes

....

-> 这是警告:

[root@test-cba ~]#sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: Warning: DocumentRoot [/var/www/vhosts] does not exist
Warning: DocumentRoot [/var/www/vhosts] does not exist

我认为您可能在启用 SELinux 的情况下运行。这需要额外的步骤才能使资源可访问(这对安全性有好处)。

这些问题包含有关如何启用文档根目录的指南:

  • https://serverfault.com/questions/293866/apache-说-文档根-不存在-当它-确实存在
  • https://serverfault.com/questions/323511/selinux-on-rhel6-httpd-config-documentroot-path-does-exist-does-not-exist

如果你不想使用 SELinux,你可以通过在/etc/selinux/config 中设置 SELINUX=disabled 来禁用它。如果您想了解更多信息,以下链接可能会有所帮助。

  • http://wiki.centos.org/HowTos/SELinux
  • http://fedoraproject.org/wiki/SELinux

尝试在 html 文件夹中移动您的 vhosts 文件夹,并通过运行

chcon -R --reference=/var/www/html /var/www/html/vhosts

最新更新