【问题标题】:rails passenger doesn't boot correctlyrails 乘客无法正确启动
【发布时间】:2010-12-15 11:12:05
【问题描述】:

我正在尝试使用配置了 mongrel 集群的旧 Rails 2.1 应用程序。

使用此配置在我的系统 (apache) 上正确安装了乘客

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5
PassengerRuby /usr/bin/ruby1.8

RailsSpawnMethod smart
PassengerMaxPoolSize 1
PassengerMaxInstancesPerApp 1
PassengerPoolIdleTime 2000
RailsFrameworkSpawnerIdleTime 0
RailsAppSpawnerIdleTime 0

我的项目位于

/var/sites/site

这是apache配置

<Virtualhost tagi:80>
  ServerName site.com
  ServerAlias www.site.com

  DocumentRoot /var/sites/site/current/

  #PassengerHighPerformance on
  ##PassengerMaxRequests 5000
  PassengerStatThrottleRate 5

  <Directory />
    AllowOverride AuthConfig
  </Directory>

  ErrorLog /var/log/apache2/site-error.log
  CustomLog /var/log/apache2/site-access.log combined
  ServerSignature Off
</Virtualhost>

使用 mongrel 应用程序可以正确启动并完美运行。 但是使用 apache2 + passanger,启动不起作用,我从 apache 获取默认目录列表。

这是配置文件的权限

-rw-r----- 1 git web 2.7K 2009-11-11 11:34 boot.rb
-rw-r----- 1 git web  600 2009-11-11 13:51 database.yml
-rw-r----- 1 git web 1.7K 2009-11-11 11:34 deploy.rb
-rw-r----- 1 git web 3.9K 2009-11-11 14:04 environment.rb
drwxr-x--- 2 git web 4.0K 2009-11-11 11:34 environments
-rw-r----- 1 git web  754 2009-11-11 11:34 gmaps_api_key.yml
drwxr-x--- 2 git web 4.0K 2009-11-11 11:34 initializers
-rw-r----- 1 git web 1.8K 2009-11-11 11:34 routes.rb

我不知道。 apache日志一目了然。

在我的服务器上,我已经有 5 个使用相同配置运行的应用程序。

有什么建议吗?

【问题讨论】:

    标签: ruby-on-rails apache passenger


    【解决方案1】:

    DocumentRoot 指向您的应用程序public 目录。我不确定/var/sites/site/current/ 是什么,但这可能不是您想要的。

    您还可以尝试通过在您的虚拟主机中输入RailsBaseURI /,更明确地向乘客解释您希望它在哪里安装 rails 应用程序。

    试一试,我们可以从那里开始。

    【讨论】:

    • thnx,/current 是正确的(使用 capistrano 部署)但我忘记 /public 在我的路径 /var/sites/site/current/public 是正确的路径。我需要暂停一下:)
    【解决方案2】:

    在这个问题上挣扎了很久。我发现让它工作的方法,特别是在不同环境(生产、调试、测试等)运行多个乘客实例时,是这样做的:

    NameVirtualHost *:80
    
    <VirtualHost *:80>
            ServerName server.com
            ServerAlias www.server.com
            DocumentRoot /var/sites/current/public
            RailsBaseURI /current
            RailsEnv production
    </VirtualHost>
    
    <VirtualHost *:80>
            ServerName dev.server.com
            DocumentRoot /var/sites/dev-version/public
            RailsBaseURI /dev-version
            RailsEnv development
    </VirtualHost>
    

    然后从 /var/sites/ 设置符号链接以指向

    lrwxrwxrwx 1 root root 13 Aug 24 17:41 current -> /code/site5
    lrwxrwxrwx 1 root root 19 Aug 24 17:41 test-version -> /code/site-test
    lrwxrwxrwx 1 root root 19 Sep 21 09:41 dev-version -> /code/development
    

    通过这种方式,Passenger 可以分辨站点之间的差异,因为它们的所有 DocumentRoot 路径都不同。如果您直接指向代码目录而不是通过符号链接,则可能不会遇到此问题。

    【讨论】:

      猜你喜欢
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      • 2014-03-13
      • 1970-01-01
      • 1970-01-01
      • 2017-02-15
      • 2012-03-14
      • 2014-08-01
      相关资源
      最近更新 更多