Personal tools
You are here: Home Linux Fixing SELinux Content in a HTML directory

 

Document Actions

Fixing SELinux Content in a HTML directory

by Mark Allen last modified 2008-09-13 13:51

Unable to access web files in a directory under the /var/www/html becuase of a 403 forbidden might be a context problem.

Problem

Getting a 403 forbidden error message when accessing a new file or directory in /var/www/html.

Check /var/log/messages to see if there are any:

Sep 13 13:11:28 fserver02 kernel: audit(1221336688.892:14): avc:  denied  { getattr } for  pid=25036 comm="httpd" name="phpldapadmin" dev=dm-0 ino=2441537 scontext=root:system_r:httpd_t tcontext=root:object_r:user_home_t tclass=dir

Solution


First check the context on the root directory.

cd /var/www/html
ls -Z index.html
-rw-r--r--  root     root     root:object_r:httpd_sys_content_t index.html

Look at the context of the new directory or file

ls -Z index.php
-rw-r--r--  root     root     root:object_r:user_home_t index.php

Now change the file or directory to the correct context

chcon  root:object_r:httpd_sys_content_t . -Rc

Check the context of the file:

ls -Z index.php
-rw-r--r--  root     root     root:object_r:httpd_sys_content_t index.php





Ads
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: