Fedora 16: “Permission denied: file permissions deny server access”

fedorapermissionsselinux

I'm working with a fresh Fedora 16 install and I'm trying to get Apache up and running. I'm very familiar with Linux and somewhat with CentOS, but I have very little experience with Fedora and SELinux (whatever that is).

At first, after installing Apache, I couldn't even see the example webpage. I did some searching and finally fixed that problem by editing the iptables.

sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
sudo iptables-save

I went ahead and started dropping some files in the web root, making sure the permissions were set correctly.

$ ls -Rlhp /var/www/html/
/var/www/html/:
total 8.0K
drwxr-xr-x. 2 apache root 4.0K Apr 20 22:47 files/

/var/www/html/files:
total 25M
-rw-r--r--. 1 apache users 25M Apr 20 22:47 SRR022918.errors.tar.gz

But then when I navigated to the corresponding URL (my.server.edu/files/SRR022918.errors.tar.gz), I got a 403 Permission denied error. I checked the Apache error log and found this message.

[Fri Apr 20 23:09:55 2012] [error] [client xxx.xxx.xx.xx] (13)Permission denied: file permissions deny server access: /var/www/html/files/SRR022918.errors.tar.gz

I tried setting file and directory permissions to 777, but that didn't solve the problem. This is really fishy, so I'm guessing this has something to do with SELinux. I have no experience with SELinux, so am I on the right track? If so, how do I fix this?

Best Answer

If memory serves, you probably need to run chcon -R -h -t httpd_sys_content_t /var/www/html

This recursively sets your content directory to the proper context for Apache.