Stumped by (13)Permission denied: file permissions deny server access ?

In: Uncategorized

8 Dec 2011

I was just pretty stumped by the following Apache error, in /var/log/httpd/error_log:

[Thu Dec 08 21:53:28 2011] [error] [client 192.168.1.2] (13)Permission denied: file permissions deny server access: /var/www/html/aml/i
ndex.html

The error implies it’s a filesystem permissions issue, and the Apache site explains that it’s almost always related to filesystem permissions, not Apache configuration. But this was exasperating, because the file ownership was apache.apache, and index.html was chmod 755. Apache could absolutely access it. But then the Apache docs made a passing mention that sometimes it was related to SELinux errors.

Sure enough, that’s exactly my problem:

[matt@bos aml]$ ls -alZ
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 .
drwxr-xr-x. root   root   system_u:object_r:httpd_sys_content_t:s0 ..
-rw-r--r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 .htaccess
drwxr-xr-x. apache apache unconfined_u:object_r:user_home_t:s0 images
-rw-r--r--. apache apache unconfined_u:object_r:user_home_t:s0 index.html
drwxr-xr-x. apache apache unconfined_u:object_r:user_home_t:s0 stylesheets

Note that the directory, and the .htaccess file I touched, have the httpd_sys_content label, which is appropriate here. But the other files show user_home_t. This apparently precludes Apache from being able to see them.

Where this went wrong is that, to get them onto the server, I scp’ed them from my desktop to my home directory on the webserver, and then cp’ed them to /var/www/html. In doing so, they picked up the user_home_t label since they were in my home directory.

A quick sudo restorecon -r . got everything sorted out. There may be a more elegant way, but this worked for me.


Related posts:

  1. MySQL Replication – Permission Denied Errors
  2. Weave
  3. Truncating a Log File
  4. Windows File Sharing
  5. video.exe is bad

12 Responses to Stumped by (13)Permission denied: file permissions deny server access ?

Avatar

i5junkies

January 30th, 2012 at 4:37 pm

Thanks for this posting. It helped me fix the problem and running. GREAT post!!!

Avatar

Philip

February 7th, 2012 at 5:42 am

Thank you for this.

Avatar

Georgi

March 6th, 2012 at 10:58 am

Thank you VERY much for posting that out! Exact same problem here, mother of god, do I hate selinux…

Avatar

Chris

March 9th, 2012 at 4:47 am

This post was exactly the solution to the error I was getting, thanks.

Avatar

bob

May 7th, 2012 at 2:58 pm

THANKS! I had no idea this was a thing. Saved my day.

Avatar

Bobby W

May 31st, 2012 at 3:48 pm

Had the same problem, yours didnt work exactly. I did sudo restorecon *

and restarted apache and it worked.

Avatar

Greg

June 17th, 2012 at 11:59 pm

Thank you thank you thank you!

Avatar

Marius

September 30th, 2012 at 9:09 am

Thanks a lot! I was really getting annoyed by this and the Web wasn’t helping.

Avatar

zaini

October 16th, 2012 at 2:05 am

Thank you so much! it worked :))

Avatar

elie

December 27th, 2012 at 6:43 pm

thank you a thousand time ;)

Avatar

TC

January 5th, 2013 at 5:01 pm

Thank you. Exactly what I was looking for.

Avatar

hela

March 31st, 2013 at 8:23 am

Thank you. Exactly my error.

Comment Form

On Other Sites

  • Matt: Hey Victor, A couple good resources for you... http://www.scanboston.com/boston.htm is really det [...]
  • victor: Hi i just got a uniden bearcay scanner and have no local or regional frequency directory.just 1 460 [...]
  • Matt: I do use them periodically. I bought a few i760's, for perhaps $10 apiece in a lot, on eBay a while [...]
  • Marin: Did you eventually end up going with an iDEN phones using Direct Talk? I had some i560's a few year [...]
  • Dan: fyi, EOD = explosive ordnance disposal [...]