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.
Thanks for this posting. It helped me fix the problem and running. GREAT post!!!
Thank you for this.
Thank you VERY much for posting that out! Exact same problem here, mother of god, do I hate selinux…
This post was exactly the solution to the error I was getting, thanks.
THANKS! I had no idea this was a thing. Saved my day.
Had the same problem, yours didnt work exactly. I did sudo restorecon *
and restarted apache and it worked.
Thank you thank you thank you!
Thanks a lot! I was really getting annoyed by this and the Web wasn’t helping.
Thank you so much! it worked :))
thank you a thousand time 😉
Thank you. Exactly what I was looking for.
Thank you. Exactly my error.
Thank you. Exactly my error.
This post was exactly the solution to the error I was getting, thanks.
Thnks funciono !!!!
Was confused by this big time… SELinux hasn’t caught me out in a long time. Good post, saved me a fair bit of time!
THANK YOU SIR!! had tried many things but this was the ultimate solution…
Bobby W. is right! sudo restorecon * then restart apache works!!
Thanks, Bobby..:)
Thanks SO much. I had no idea SELinux was getting in the way.
Thank you so much for this! I had the same issue, and was bemused. For the same reason… I put it on my desktop then SCPed which I rarey do.
I found just -r didn’t work. I had to do -r *.
Thanks!
Thanks a lot. i was going mad to solve this issue
Thank you!!
Thanks heaps, you saved the day! This exact problem has been driving me bananas all day. Much appreciated!
Thanks a lot, I had almost lost all hope, your post saved me.
If you were here I’d kiss you, I have just spent hours trying to solve this and your blog post fixed it in a moment. Thank You!
Thanx thanx thanx thaaaanx is work is worked I am grateful to you too
Thank you <3
This post solved my problem, thank you.
You saved me from a lot of search – thank you!
When you see this kind of error in Linux, check you /etc/passwd file and change the
change the info from /nologin to below
apache:x:48:48:Apache:/var/www:/bin/bash
What??? Why would you do that? The selinux (sudo restorecon .) solution elsewhere make sense. This does not.
Agreed, GB. Do not give the apache user a bash shell in /etc/passwd. It’s “nologin” for a reason.
Super,
funciona muy bien gracias por el aporte
YESSS!! work funcional very good, thanks yours post
6 Years and some months later this has worked for me today, thank you!
OMG This is what? 10 years later and you just solved a problem I had been struggling with for way too long. Thank you!
Thank you so much. This was my problem.