Linux (1)
SELinux (1)

Why do I get a 403 forbidden when I try to access content in a subdirectory under the doc root with Apache httpd?

I install the Apache web server and copy a directory of stuff into a subdirectory under the document root but get a 403 forbidden when trytin to access it. How do I fix it?

It could be standard file system permissions, but if you have SELinux enabled, that could be your culprit. To see, enter:

setenforce 0

to disable SELinux and try to hit a file in your subdirectory. If you don't get a 403, then you need to set the SELinux security context on the directory/files. You can see the extended SELinux permission information via:

ls -Z

You can set the security context recursively with chcon -R

Here is an example:

chcon -R user_u:object_r:httpd_sys_content_t ar that sets the contenxt on ar and everything in it.

If SELinux is not the problem: All directories under the doc root must have at least +x permission bits set, so assuming your directory is "mydir", in its parent, enter chmod +x mydir. Also make sure files in the directory are readable (chmod 644 on the file will do it). If that lets you get to a file under "mydir", then set permissions for files and directories in the "mydir" directory tree.


Add a Comment

NOTE: Comments are moderated and will not show until approved.