apache says my DocumentRoot directory doesn't exist
Asked Answered
W

4

16

I am using Phusion Passenger to deploy a rails application using apache2 on CentOS 5.5. For some reason, I keep getting this message when I start up apache:

> service start httpd
Starting httpd: Warning: DocumentRoot [/home/deploy/my_app/public] does not exist
[ OK ]

The directory most certainly does exist. Here are some important files from my configuration:

/etc/httpd/conf/httpd.conf
...
User deploy
Group deploy
...

/etc/httpd/conf.d/my_app.conf
< VirtualHost *:80>
    ServerName my_app.com
    DocumentRoot /home/deploy/my_app/public
    < Directory /home/deploy/my_app/public>
        Allow from all
        Options -MultiViews
    < /Directory>
< /VirtualHost>

The directories /home/deploy, /home/deploy/my_app, and /home/deploy/my_app/public all belong to the deploy user.

Wacke answered 16/10, 2010 at 7:26 Comment(3)
What are the permissions on the directories? I'm not an expert, but the first thing that came to mind was that even though you've named the correct user in httpd.conf, it's not necessarily that user which checks if the directory exists...Frederik
I set everything to either rwxrwxrwx or rwxrw-rw-. root owns /home and deploy owns everything else along the way to /home/deploy/my_app/public. Thanks, though.Wacke
An answer to another question might help future finder running across this question; it surveys a number things related to web servers and SELinux : serverfault.com/a/551801/101931Necessaries
L
17

I ran into this problem too. Are you running SELinux? Check /etc/sysconfig/selinux, or try echo "0" >/selinux/enforce as root to see if disabling it helps.

If so, you can either modify your selinux policy to allow access to these files, or just disable selinux altogether.

Laurynlausanne answered 16/10, 2010 at 7:26 Comment(3)
I'm encountering the same problem as @muirbot, and this solution didn't help.Frivolous
Same. Using the temporary setenforce 0 works, but the permanent solution doesn't. Any ideas?Neutralism
thanks for the solution. Not sure that it's permanent solutionCodel
R
2

Instead of turning off SELinux you should be able to fix the context issue fairly easily.

You can check the current contexts of your public directory with the following command.

ls -Z /home/deploy/my_app/

If you have a different path on your server that is working (ex: /home/deploy/foo/bar/), check it using the same command and compare with the previous results.

ls -Z /home/deploy/foo/

The Fix: You can then just copy the context from the working directory like this...

chcon /home/deploy/my_app/public/ --reference=/home/deploy/foo/bar/
Replevy answered 11/11, 2013 at 14:20 Comment(0)
F
0

Please Check whether the /etc/sysconfig/selinux file has execute privilage. If no, grant execute privilage, restart the web server and then try again to acces the page

Faruq answered 18/5, 2012 at 7:26 Comment(0)
A
0

I had the same problem and found this:

https://www.centos.org/forums/viewtopic.php?t=1742#p9988

Utilizing the semanage tool isn't that hard and, as far as I can tell, is how SELinux is supposed to be used. I believe this is safer than turning it off entirely.

example from provided link:

[root@elite user]# semanage fcontext -a -t public_content_rw_t '/home/user(/.*)?'
[root@elite user]# restorecon -R /home/user
Abamp answered 12/3, 2014 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.