【问题标题】:Ubuntu - Apache - Rails - Passenger - Spawning errorUbuntu - Apache - Rails - 乘客 - 生成错误
【发布时间】:2012-11-07 16:28:19
【问题描述】:

我遇到了乘客抱怨的错误:

*** Passenger ERROR (ext/common/ApplicationPool/../SpawnManager.h:220):
Could not start the spawn server: /usr/local/rvm/gems/ruby-1.9.3-head/ruby: No such file or directory (2)
[ pid=8970 thr=139698295748416 file=ext/apache2/Hooks.cpp:865 time=2012-11-07 17:17:32.422 ]: Unexpected error in mod_passenger: Cannot spawn application '/www/lensfinder.se/ruby/lensfinder': Could not read from the spawn server: Connection reset by peer (104)
  Backtrace:
     in 'virtual Passenger::SessionPtr Passenger::ApplicationPool::Client::get(const Passenger::PoolOptions&)' (Client.h:750)
     in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&)' (Hooks.cpp:297)
     in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:566)

据我所知,虽然 /www/lensfinder.se/ruby/lensfinder 存在,但它无法访问。

我在 Phusion Passengers site 上找到了这个常见问题解答

问题是,当我尝试使用该命令时,

passenger-config --root

我明白了:

-bash: /usr/bin/passenger-config: ruby: bad interpreter: No such file or directory

apache 配置:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
   PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-head/ruby

<VirtualHost 10.0.0.37:80>
    ServerAdmin webmaster@compartment.se
    DocumentRoot /www/lensfinder.se/htdocs
    ServerName lensfinder.se
Redirect 301 / http://www.lensfinder.se/
    ErrorLog /var/log/apache2/lensfinder.se-error.log
    CustomLog /var/log/apache2/lensfinder.se-access.log combined
</VirtualHost>
<VirtualHost 10.0.0.37:80>
    ServerAdmin hostmaster@compartment.se
    ServerName lensfinder.se
    ServerAlias www.lensfinder.se
    ServerAlias *.lensfinder.se
#   DocumentRoot /www/lensfinder.se/htdocs
    DocumentRoot /www/lensfinder.se/ruby/lensfinder/script
    <Directory />
        Options FollowSymLinks
        AllowOverride all
    </Directory>
    <Directory /www/lensfinder.se/htdocs>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /www/lensfinder.se/cgi-bin/
    <Directory "/www/lensfinder.se/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
        AllowOverride AuthConfig
#Options Includes
#Options FollowSymLinks
#Options +Indexes +Multiviews +FollowSymLinks
    </Directory>
    <Directory "/www/lensfinder.se/htdocs/usage">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
        AllowOverride AuthConfig
#Options Includes
#Options FollowSymLinks
#Options +Indexes +Multiviews +FollowSymLinks
    </Directory>
    ErrorLog /var/log/apache2/lensfinder.se-error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog /var/log/apache2/lensfinder.se-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>


Alias /ruby/ /www/lensfinder.se/ruby/lensfinder/script
        <Directory /www/lensfinder.se/ruby/lensfinder/script>
#       Options ExecCGI
#       AddHandler cgi-script .cgi
#       Addhandler fastcgi-script .fcgi .fcg .fpl
        AllowOVerride all
        Order allow,deny
        Allow from all
        </Directory>

<IfModule passenger_module>
   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
   PassengerRuby /usr/local/rvm/gems/ruby-1.9.3-head/ruby
</IfModule>

RailsEnv production
RailsBaseURI /script



#
<Location />
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</Location>

</VirtualHost>

【问题讨论】:

  • 我们能看到你的这个虚拟主机的 apache 配置吗?
  • @AnthonyAlberto - 是的,查看更新的答案!
  • 您的配置实际上很混乱......您的包含 Rails 应用程序的文件夹在哪里?
  • @AnthonyAlberto - /www/lensfinder.se/ruby/lensfinder

标签: ruby-on-rails-3 ubuntu apache2 passenger spawning


【解决方案1】:

好吧,我猜你把Passenger指向了错误的目录。您应该将其指向 Rails 应用程序的 public 目录。

这是您项目的极简配置,位于/etc/apache2/sites-available/lensfinder.se

<VirtualHost 10.0.0.37:80>
  ServerAdmin hostmaster@compartment.se
  ServerName lensfinder.se
  ServerAlias *.lensfinder.se

  DocumentRoot /www/lensfinder.se/ruby/lensfinder/public
  RailsEnv production

  <Directory "/www/lensfinder.se/ruby/lensfinder/public">
    Options FollowSymLinks
    AllowOverride All
    Options -MultiViews
  </Directory>

</VirtualHost>

然后编辑/etc/apache2/apache2.conf并在文件末尾添加:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-head/ruby

然后 simlink 您的虚拟主机配置以启用它:

ln -s /etc/apache2/sites-available/lensfinder.se /etc/apache2/sites-enabled/lensfinder.se 

当然要重启 apache2

【讨论】:

  • 当然,但这应该放在一般的/etc/apache2/apache2.conf中,而我上面所做的配置转到/etc/apache2/sites-available然后你simlink文件在sites-enabled中,这是标准的方法做吧
  • 好的,但是如果我有不使用乘客的虚拟主机,如果我将它添加到通用配置中会不会有问题?
  • 完全没有,如果不是 Rails 应用程序,Passenger 不会处理它。但是,如果您有其他 Rails 应用程序并且不想让乘客处理它们,而是使用独角兽或其他什么,请使用 RailsAutoDetect off,请参阅此处的文档:modrails.com/documentation/…
  • 如果我有多个网站使用不同的 ruby​​ 版本,...?
  • 从Passenger 3.2开始,你将能够为每个虚拟主机切换ruby版本......虽然它还没有出来,仍然处于preview状态但显然它已经发布了所以你可以测试一下
【解决方案2】:

除了previous answer,就我而言,即使在编辑了配置文件之后,我在加载 Apache 时仍然遇到问题,因为该模块仍被配置为加载以前的(全局).so 文件。

我发现/usr/local/rvm/gems/[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/ext/apache2/ 目录中有源文件和脚本,但没有二进制文件。然而,提供了构建这些脚本的脚本。只需运行sudo /usr/local/rvm/gems/ruby-[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/bin/passenger-install-apache2-module

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多