02.12.09
Changing DocumentRoot in Apache: files, directories and permissions
While setting up a WSGI-hosted django app on Fedora 10, I could not get apache to serve any files that weren’t stored under /var/www/. I tried
- changing the
DocumentRoot - using the
AliasDirective - using symbolic links from
/var/wwwto the required location chmod -R go=rx path/to/my/fileschown -R apache path/to/my/files- Changing the User and Group apache runs under
All to no avail. By symlinking to my directory I could get apache to list directory contents, but trying to access any files within gave a 403 forbidden error. It turns out the problem was to do with SELinux - by default the security policy is set to ‘enforcing’. I changed the policy to ‘permissive’ and all was well.
It took me an embarrassingly long time to figure this one out - I thought it was caused by a combination of apache configuration and filesystem permissions, but it turned out the security policy had a role to play too.