0

I've got the error where passenger complains that:

*** 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)

From what I can read is that it cant access /www/lensfinder.se/ruby/lensfinder though it exist.

And I found this FAQ on Phusion Passengers site

The problem is that, when I try to use that command,

passenger-config --root

I get this:

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

apache config:

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>
Philip
  • 6,827
  • 13
  • 75
  • 104

2 Answers2

1

Ok my guess is that you point Passenger to the wrong directory. You should point it to the public directory of your Rails app.

Here's a minimalist configuration for your project that goes in /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>

Then edit /etc/apache2/apache2.conf and at the end of the file, add :

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

then simlink your virtualhost config to enable it:

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

And of course restart apache2

Anthony Alberto
  • 10,325
  • 3
  • 34
  • 38
  • Of course, but this should go in the general `/etc/apache2/apache2.conf`, whereas the configuration I did above goes to `/etc/apache2/sites-available` and then you simlink the file inside `sites-enabled`, this is the standard way to do it – Anthony Alberto Nov 07 '12 at 16:48
  • Ok, but if I have virtual hosts that aren't using passenger, wouldn't it be a problem if I added this to the general conf? – Philip Nov 07 '12 at 16:50
  • not at all, Passenger won't handle it if it's not a Rails app. However if you have other Rails apps and don't want passenger to handle them, but instead use unicorn or whatever, use `RailsAutoDetect off`, see the doc here : http://www.modrails.com/documentation/Users%20guide%20Apache.html#_railsautodetect_lt_on_off_gt – Anthony Alberto Nov 07 '12 at 16:54
  • And if I have multiple sites with different ruby versions,...? – Philip Nov 07 '12 at 16:55
  • And starting from Passenger 3.2, you'll be able to switch ruby versions for each virtual host ... it's not out yet though, still in `preview` state but apparently it's been released so you could test it – Anthony Alberto Nov 07 '12 at 17:01
0

In addition to the previous answer, In my case even after editing configuration files I still had issues loading up Apache as the module was still configured to load the previous (global) .so file.

I found there were source files and scripts in the /usr/local/rvm/gems/[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/ext/apache2/ directory, but no binaries. There were however scripts provided to build those. Simply run sudo /usr/local/rvm/gems/ruby-[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/bin/passenger-install-apache2-module.

Community
  • 1
  • 1
pospi
  • 3,540
  • 3
  • 27
  • 26