How to fix Apache permission denied error due to SELinux 

Joined:
04/07/2009
Posts:
163

April 13, 2011 13:47:34    Last update: April 13, 2011 13:49:20
You get "permission denied" error from Apache HTTPD for a page. And you checked file/directory permissions (the whole directory path, not just the file) and everything in httpd.conf. If everything seemed right, then SELinux may be blocking the access.

Open /var/log/httpd/error_log, you may see a line like this:
[Wed Apr 13 15:50:35 2011] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0


These are the steps to fix:
  1. If the directory resides in a user home directory:
    # setsebool -P httpd_read_user_content 1
    

  2. Create a policy package from the audit log:
    # grep httpd /var/log/audit/audit.log | audit2allow -M mypol
    ******************** IMPORTANT ***********************
    To make this policy package active, execute:
    
    semodule -i mypol.pp
    

  3. Apply the policy package just created
    # semodule -i mypol.pp
    

  4. Restart apache httpd:
    # apachectl restart
    


Share |
| Comment  | Tags
1 comment