Friday, June 1, 2012

Apache Unable to Read Files Unless SELinux Context is Set Correctly

If you're getting a "permission denied" error when Apache tries to read and serve out a file, even though the file-system permissions are correct, then it's most likely due to the SELinux context issue.

For Apache to be able to read the file, the file needs to have SELinux context something like "system_u:object_r:httpd_sys_content_t:s0"

To find out the current SELinux context of files, "ls -alZ"

To change the SELinux context of a file:
chcon <Context> <File>
e.g. chcon system_u:object_r:httpd_sys_content_t:s0 index.html

No comments:

Post a Comment