How to permanently change the context of a directory.

General How Tos, which are NOT OS specified

Moderator: xeont

How to permanently change the context of a directory.

Postby Henrycoffin » Thu Nov 07, 2013 12:30 pm

To change the context of a directory and all its contents.

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
Henrycoffin
 
Posts: 3
Joined: Thu Nov 07, 2013 12:10 pm

Re: How to permanently change the context of a directory.

Postby Cock145 » Thu Jan 22, 2015 11:19 am

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.





______________________________________
Cock145
 
Posts: 1
Joined: Thu Jan 22, 2015 11:13 am


Return to How Tos

Who is online

Users browsing this forum: No registered users and 1 guest