Ruby-on-rails apache 说我的 DocumentRoot 目录不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3948038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
apache says my DocumentRoot directory doesn't exist
提问by muirbot
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:
我正在使用 Phusion Passenger 在 CentOS 5.5 上使用 apache2 部署 rails 应用程序。出于某种原因,我在启动 apache 时不断收到此消息:
> service start httpd
Starting httpd: Warning: DocumentRoot [/home/deploy/my_app/public] does not exist
[ OK ]
> 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/httpd.conf
...
用户部署
组部署
...
/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>
/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.
目录/home/deploy、/home/deploy/my_app 和/home/deploy/my_app/public 都属于deploy 用户。
回答by Edward Anderson
I ran into this problem too. Are you running SELinux? Check /etc/sysconfig/selinux, or try echo "0" >/selinux/enforceas root to see if disabling it helps.
我也遇到了这个问题。你在运行 SELinux 吗?检查 /etc/sysconfig/selinux,或尝试echo "0" >/selinux/enforce以 root 身份禁用它是否有帮助。
If so, you can either modify your selinux policy to allow access to these files, or just disable selinux altogether.
如果是这样,您可以修改您的 selinux 策略以允许访问这些文件,或者完全禁用 selinux。
回答by Scruffy Paws
Instead of turning off SELinux you should be able to fix the context issue fairly easily.
您应该能够相当轻松地修复上下文问题,而不是关闭 SELinux。
You can check the current contexts of your publicdirectory with the following command.
您可以public使用以下命令检查目录的当前上下文。
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.
如果您的服务器上有不同的工作路径(例如:/home/deploy/foo/bar/),请使用相同的命令检查它并与之前的结果进行比较。
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/
回答by dayer4b
I had the same problem and found this:
我有同样的问题,发现这个:
https://www.centos.org/forums/viewtopic.php?t=1742#p9988
https://www.centos.org/forums/viewtopic.php?t=1742#p9988
Utilizing the semanagetool 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.
使用该semanage工具并不难,据我所知,这就是应该如何使用 SELinux。我相信这比完全关闭它更安全。
example from provided link:
提供的链接中的示例:
[root@elite user]# semanage fcontext -a -t public_content_rw_t '/home/user(/.*)?'
[root@elite user]# restorecon -R /home/user
回答by Varghese VS
Please Check whether the /etc/sysconfig/selinuxfile has execute privilage. If no, grant execute privilage, restart the web server and then try again to acces the page
请检查/etc/sysconfig/selinux文件是否有执行权限。如果没有,授予执行权限,重新启动 Web 服务器,然后再次尝试访问该页面

