in Linux

Apache 403 Forbidden error

I added additional folder for browser to access, Apache encountered and returned error: 403 Forbidden,

Forbidden

You don’t have permission to access /pub/ on this server.

 

searched the solution,

1, changed the httpd.conf folder access attribute, still not working,

 Require all granted

2, changed SELinux,

changed two booleans, still not working,

‘httpd_enable_homedirs’ boolean and ‘httpd_read_user_content’ boolean

3, changed SELinux context, resolved, as the one person in the internet mentioned,

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.

Yes, I have done some mv action of the folder, needs to restore the selinux context, resolved!

restorecon -r /var/www/pub

Write a Comment

Comment

2 × four =