【问题标题】:How to Serve Rails Web App with Apache and Passenger如何使用 Apache 和 Passenger 服务 Rails Web 应用程序
【发布时间】:2014-03-25 08:32:32
【问题描述】:

我正在使用 ubuntu12.04 和 apache2 在 digitalocean vps 上为 eurohacktrip.org 提供服务。

这是我的 apache 虚拟主机文件:/etc/apache2/sites-available/eurohacktrip.org

<VirtualHost *:80>
    ServerName eurohacktrip.org
    ServerAlias eurohacktrip.org

    DocumentRoot /var/www/eurohacktrip.org/public

    RailsEnv production
    PassengerEnabled on
    PassengerAppRoot /var/www/eurohacktrip.org/
    PassengerRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
    ServerAdmin webmaster@eurohacktrip.org

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/eurohacktrip.org/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            # Order allow,deny
            Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

我在 /etc/apache2/apache2.conf 中添加了这些行

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.40/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.40
  PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
</IfModule>

我做到了

service apache2 restart

但我的网站仍然无法正常工作:http://eurohacktrip.org/
够奇怪了 3000 http://eurohacktrip.org:3000就可以用了

我也不得不取消注释

gem 'therubyracer', platforms: :ruby 

然后跑了

bundle install

但仍然没有运气。可能缺少什么?

【问题讨论】:

  • 根据你的进度,我会考虑使用 Digital Ocean 的预建 Nginx/Unicorn 服务器,而不是手动设置 apache/passenger
  • 它应该开箱即用。
  • 看起来乘客正在独立模式下运行,在这种情况下,可以使用 --port 选项指定端口号。

标签: ruby-on-rails ruby apache ubuntu


【解决方案1】:
 LoadModule passenger_module /home/deployer/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.40/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/deployer/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.40
     PassengerDefaultRuby /home/deployer/.rvm/gems/ruby-1.8.7-p374/wrappers/ruby
   </IfModule>
        <VirtualHost *:80>
              ServerName yourservername
              RailsEnv production
              # !!! Be sure to point DocumentRoot to 'public'!
              DocumentRoot /home/user/apps/projects/myapp/public
              <Directory /home/user/apps/projects/myapp/public>
                 # This relaxes Apache security settings.
                 AllowOverride all
                 # MultiViews must be turned off.
                 Options -MultiViews
              </Directory>
        </VirtualHost>

如果您遇到任何问题,请点击此链接

http://nathanhoad.net/how-to-ruby-on-rails-ubuntu-apache-with-passenger

【讨论】:

    【解决方案2】:

    事实证明,我根本没有阅读乘客错误页面上的说明。我只需要禁用 gem “simple-captcha”,运行 bundle install ,一切就恢复正常了。谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 2011-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      相关资源
      最近更新 更多