1

My files are all owned by apache:apache. All directories have 770 permissions and files have 660 permissions. My original virtualhost seems to be fine but the second one is getting 403 errors on all paths.

Here's my current configuration in /etc/httpd/conf/httpd.conf

<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>
2
  • 2
    Is SELinux enabled and did you apply the correct context to the document root? Hint: restorecon -R /var/www
    – fuero
    Oct 9, 2013 at 5:37
  • That worked! Will you add that as an answer so I can accept it as such? Also, if you could explain any explanation to why it worked, that'd be awesome. Thank you.
    – eisaacson
    Oct 9, 2013 at 14:55

1 Answer 1

2

SELinux is likely to be the culprit here.

Somehow the parent's context wasn't inherited correctly when creating files/directories in the /var/www directory.

Setting the container implicitly with restorecon or explicitely with chcon should fix the issue.

Watch out for lines in /var/log/audit.log when you are troubleshooting issues in a SELinux setting.

To fix the issue at hand, run:

# restorecon -R /var/www

as root. This will restore /var/www's context as determined by SELinux's system policy to /var/www and all folders and files below it.

Further information on (troubleshooting) SELinux can be found here, here and here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .