在服务器上只有一个网站时,我们通常修改httpd.conf里的DocumentRoot和对应的<Directory>里的目录,然后重启Apache。就可以生效。
在CentOS 6.3,Apache 2.2.15的默认安装情况下,这一做法失效,会报Permission Denied的错误。通常的解决方案是该文件的上级目录加755的权限。但现在这样毫无用处。
查找英文网站,找到以下一段话。
If Running Security Enhanced Linux (SELinux)
Another possibility for this error is that you are running SELinux (Security Enhanced Linux), inwhich case you need to use chcon
to apply the proper security context to the directory. One easy way to do this is to copy from a directory that does work for example /var/www/
chcon -R –reference=/var/www /path/to/webroot
按照方法执行,OK了。