If you are hosting web pages in a directory in your home folder you will need to change the type for that directory and all files contained within.
- Code: Select all
# semanage fcontext -a -t httpd_sys_content_t "/home/user/html(/.*)?
Now to apply the above rule
- Code: Select all
# restorecon -F -R -v "/home/user/html/"
For this particular example there is also a boolean you may need to set to enable serving content form home directories.
Check if the httpd_enable_homedirs boolean is on
- Code: Select all
# getsebool -a | grep httpd
allow_httpd_anon_write --> off
allow_httpd_bugzilla_script_anon_write --> off
allow_httpd_mod_auth_pam --> off
allow_httpd_nagios_script_anon_write --> off
allow_httpd_squid_script_anon_write --> off
allow_httpd_sys_script_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_network_connect --> off
httpd_can_network_connect_db --> off
httpd_can_network_relay --> off
httpd_disable_trans --> off
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_rotatelogs_disable_trans --> off
httpd_ssi_exec --> off
httpd_suexec_disable_trans --> off
httpd_tty_comm --> on
httpd_unified --> on
As you can see it is currently off. To enable simply set to on.
- Code: Select all
# setsebool -P httpd_enable_homedirs on