使用乘客和apache在rails app上部署ruby

时间:2014-09-23 11:59:17

标签: ruby-on-rails apache passenger

我想在Red Hat Enterprise Linux Server 6.5版服务器上部署我的ruby on rails应用程序 我做了以下事情:

服务器版本:Apache / 2.2.15(Unix)

rvm install ruby​​

gem install rails

宝石安装乘客

passenger-install-apache2-module

然后我在httpd.conf文件中添加了以下行

   LoadModule passenger_module /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50
     PassengerDefaultRuby /home/myname/.rvm/gems/ruby-2.1.2/wrappers/ruby
   </IfModule>

alos我将以下内容添加到我的httpd.conf

   <VirtualHost *:80>
  ServerName www.whatever.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/whatever/public    
  <Directory /var/www/whatever/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
     # Uncomment this if you're on Apache >= 2.4:
     #Require all granted
  </Directory>

其他信息 rvm 1.25.31

我重新启动了httpd,我无法看到我的应用程序在whatever.com上运行 我已经购买了域名并将其重定向到我的机器的IP。 出了什么问题?

2 个答案:

答案 0 :(得分:0)

您需要取消注释下面指定的行并重新启动您的apache服务(sudo service apache2 restart或类似的sudo /etc/init.d/apache2 restart

  <VirtualHost *:80>
  ServerName www.whatever.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /var/www/whatever/public    
  <Directory /var/www/whatever/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
     # Uncomment this if you're on Apache >= 2.4:
 --->    Require all granted
  </Directory>

这是乘客默认设置的常见问题。您有可能使用较新版本的apache,这意味着#取消注释,如果您使用Apache&gt; = 2.4:将适用。

答案 1 :(得分:0)

有很多原因导致这种情况发生,@ user1876128有一些内部网络问题,而且它并没有出现问题。

要使此apache设置正常工作,您的网络需要允许http流量到服务器端口80。

建议允许端口3000上的流量,因此您可以在同一地址(加上:3000)上运行rails dev服务器,以便在它们启动之前检查所有更改。

您可以通过将浏览器指向192.168.0.1或192.168.1.1登录大多数国内路由器,然后使用密码(可以在路由器上写入,也可以使用在线查找的默认密码,或者您可以;已经改变了它)。并为端口80和服务器盒设置服务。