RHEL Apache:403在VirtualHost上禁止

我的文件全部由apache拥有:apache。 所有目录有770个权限,文件有660个权限。 我原来的虚拟主机似乎很好,但第二个是在所有path上得到403错误。

这是我在/etc/httpd/conf/httpd.conf中的当前configuration

<Directory "/var/www/site1"> Options Indexes FollowSymLinks AllowOverride All <IfModule mod_access.c> Order allow,deny Allow from all </IfModule> </Directory> <Directory "/var/www/site2"> Options Indexes FollowSymLinks AllowOverride All <IfModule mod_access.c> Order allow,deny Allow from all </IfModule> </Directory> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/site1/ ServerName site1.domain.com ErrorLog /var/log/httpd/site1.error.log CustomLog /var/log/httpd/site1.access.log common </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/site2/ ServerName site2.domain.com ErrorLog /var/log/httpd/site2.error.log CustomLog /var/log/httpd/site2.access.log common </VirtualHost> 

SELinux可能是这里的罪魁祸首。

/var/www目录中创build文件/目录时,父母的上下文不会被正确地inheritance。

使用restorecon隐式设置容器或者使用chcon显式设置容器应该可以解决这个问题。

当您在SELinux设置中解决问题时,请注意/var/log/audit.log中的行。

要解决这个问题,运行:

# restorecon -R /var/www

作为根。 这将恢复/var/www的上下文,由SELinux的系统策略确定为/var/www以及其下的所有文件夹和文件。

有关(故障排除)SELinux的更多信息可以在 这里和这里find 。