Apache 403:Forbidden on sub-directory

Fix: restorecon -r /var/www/html

The issue is caused when you mv something from one place to another. It preserves the selinux context of the original when you move it, so if you untar something in /home or /tmp it gets given an selinux context that matches its location. Now you mv that to /var/www/html and it takes the context saying it belongs in /tmp or /home with it and httpd is not allowed by policy to access those files.

If you cp the files instead of mv them, the selinux context gets assigned according to the location you’re copying to, not where it’s coming from. Running restorecon puts the context back to its default and fixes it too.

Related posts

Check Log for cPanel password change

cat /usr/local/cpanel/logs/access_log | grep changepass.html
cat /usr/local/cpanel/logs/access_log | grep username

cat /var/cpanel/accounting.log | grep username

Useful Exim Commands

exigrep domain.com /var/log/exim_mainlogcat /home/username/.contactemailexim -bpc

List the messages in the queue:exim -bop

List frozen mais:exit -bp...

Monitoring Commands:

To know uptime and other parameters:

echo -n `uptime` && echo " - Cores: `grep...

Latest posts

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *