我试图让乘客工作,但我一直看到 apache 默认页面。我在 inmotion VPS 上使用 centos 6.3。这是我到目前为止所做的:
- gem 安装乘客。
- rvmsudo Passenger-install-apache2-module
将以下代码粘贴到/usr/local/apache/conf/includes/post_virtualhost_global.conf (这会加载到 httpd.conf 中)
LoadModule passenger_module /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so PassengerRoot /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17 PassengerRuby /home/username/.rvm/wrappers/ruby-1.9.3-p194/ruby
<VirtualHost 123.123.123.123:80> ServerName http://XXXXXX.inmotionhosting.com # !!! Be sure to point DocumentRoot to 'public'! DocumentRoot /home/username/rails/current/public <Directory /home/username/rails/current/public> # This relaxes Apache security settings. AllowOverride all # MultiViews must be turned off. Options -MultiViews </Directory> </VirtualHost>
编辑:不确定为什么格式不正确。它在文本编辑器中的线条和选项卡都很好。
在 etc/hosts 中有一行:
123.123.123.123 XXXXXX.inmotionhosting.com XXXXXX
我通过/etc/init.d 中的 sudo service httpd restart 重新启动了 apache
- 仍然显示 apache 默认页面
有什么想法吗?谢谢
最佳答案
我偶然发现了这篇 1 年前的帖子,解决了类似的问题,但没有一条评论对我有用。所以我只是为那些寻求帮助的人添加我的 2 美分。
如果您看到 Apache 默认页面,则意味着 phusion Passenger 可能未运行。当您启动/停止/重新启动 apache 服务器时,您可能会看到一条警告消息,提示 phusion 乘客模块已加载,正在跳过。
因此 Apache 已跳过您在 conf 文件中添加的最新 LoadModule 行。
然后检查apache配置文件中错误日志设置目录中的error.log。 (centos 的 httpd.conf)
就我而言,它提示在 PassengerRuby 中设置的目录中找不到看门狗。这证实了加载的乘客模块不是我刚刚添加的。发生这种情况可能是因为我现在正在使用 RVM,但不久前还以 root 身份安装了旧版本的 Passenger。于是我查看了Apache root下的config.d目录,有一个文件“passenger.conf”正在加载旧版本的Passenger。
我删除了该文件,按原样保留新的 LoadModule - 从 Phusion Passenger 在安装 apache2-module 时给我的指令复制,重新启动 apache 服务器,没有警告消息,并且乘客工作了。
关于ruby-on-rails-3 - 设置乘客 : keeps showing apache default page instead,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12920175/