[CentOS] Forbidden: can't access *.html files in /var/www/html

Wed Sep 29 15:13:10 UTC 2010
Jay Leafey <jay.leafey at mindless.com>

Alexander Farber wrote:
> Hello,
> 
> I'm using the latest CentOS with phpBB 3.0.x + postgreSQL + sendmail
> (relayed through gmail.com) - all those programs working fine,
> with no big modifications of the CentOS defaults (i.e. SELinux is on).
> 
> Now I'm struggling with the seemingly simple problem, that when
> I put an .html file into /var/www/html/ then Apache won't serve it.
> 
> <SNIP>
> 
> I've looked into /etc/httpd/conf/httpd.conf and conf.d/ files...
> 
> Does anybody know what is wrong, how to find out?
> 
> Regards
> Alex

Did you possibly use mv to put the file in that directory?  If so, it 
will not always set the file context properly.  You can tell if you will 
check to see if SELinux is active (run getenforce and see if it returns 
"Enforcing") and use the -Z switch to ls to see the file context of the 
problem files.  If the context is not "httpd_sys_content_t" or something 
similar you need to fix the context.

Fixing it is easy, just run restorecon:

restorecon -rv /var/www/html

This will walk down the directory tree and fix up the file contexts, 
giving you a message about the files it changes.

Of course, if it isn't an SELinux problem, this won't help.
-- 
Jay Leafey - jay.leafey at mindless.com
Memphis, TN
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5529 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.centos.org/pipermail/centos/attachments/20100929/837e31b9/attachment-0005.bin>