Rails:Apache和Passenger的Vhost配置

时间:2014-01-24 11:29:36

标签: apache ruby-on-rails-4 apache2 passenger

我试图在我的服务器上部署一个简单的Rails 4应用程序,该应用程序已经拥有Apache2并且正在托管其他几个站点和服务(即在启用站点的情况下有几个vhost配置)。我在本地计算机和测试服务器上执行此操作时遇到了一些问题,因此我首先尝试使用仅有一个vhost配置的AWS t1.micro实例。我已经写了一个脚本来为我完成大部分繁重的工作,我在rails-apache-passenger的github上。

我在repo中有两个vhost配置文件,并尝试让其中一个工作。该脚本只是复制并一次启用一个。

使用 my-ruby-app-basic my-ruby-app vhost配置,我导航到http://54.xxx.xxx.xxx/my-ruby-app/,但我看到的只是&# 34;您要查找的页面不存在。您可能输错了地址或页面可能已移动。"当我转到ttp://54.xxx.xxx.xxx/时,我只得到默认的apache2页面("它可以工作!")。

我的/var/www/my-ruby-app/log/production.log显示

I, [2014-01-24T10:47:36.900542 #9612]  INFO -- : Started GET "/my-ruby-app" for 80.81.17.94 at 2014-01-24 10:47:36 +0000
F, [2014-01-24T10:47:36.902169 #9612] FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/my-ruby-app"):

很明显我需要修改我的routes.rb文件,但是我应该改变什么?正如您从git repo中的脚本中看到的那样,它只是来自rails new的默认routes.rb。我只想在此时看到默认的rails app登录页面,所以我不确定如何处理routes.rb文件。

以下是vhost配置

我-红宝石APP-基本

#This is the config suggested by the passenger module after it finishes compiling, modified for 'my-ruby-app'
<VirtualHost *:80>
  ServerName www.my-ruby-app-host.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/my-ruby-app/public    
  <Directory /var/www/my-ruby-app/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
  </Directory>
</VirtualHost>

我-红宝石应用

#Based on Apache section of Passenger documents
<VirtualHost *:80>
  ServerName www.my-ruby-app-host.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/
  <Directory /var/www/>
     Allow from all
  </Directory>

  Alias /my-ruby-app /var/www/my-ruby-app/public
  <Location /my-ruby-app>
     PassengerBaseURI /my-ruby-app
     PassengerAppRoot /var/www/my-ruby-app
  </Location>
  <Directory /var/www/my-ruby-app/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
  </Directory>
</VirtualHost>

使用Apache和Passenger是一个短期解决方案,但我想知道如何在任何情况下都这样做(长期观点是我想保持与Jruby的兼容性,只需通过Tomcat或Glassfish运行我们的应用程序,毫无疑问是另一个Apache配置崩溃;-))

0 个答案:

没有答案