-->

Pages

Wednesday, 18 April 2012

Adding Apache document root permission to SELinux

On redhat linux with SELinux enabled, merely changing the document root path in the /etc/httpd/conf/httpd.conf file is not enough to make Apache work with the new location. Apache will give "File Not Found" error. To fix this problem, just use the following script. Make sure to change $HTTP_DOC to the location of the new apache document root.

#!/bin/sh

HTTP_DOC=/home/www/html

setsebool -P httpd_enable_homedirs on
chmod 755 $HTTP_DOC
chown -R apache.apache $HTTP_DOC
chcon -R -t httpd_sys_content_t $HTTP_DOC
 

1 comment:

  1. thank you kind sir. I only had information for the last part of the script and was under permission hell

    ReplyDelete