1
votes

I'm attempting to configure Apache V2 to handle two Rails (3.2.2) applications at the same time using VirtualHost directives. I'm doing this on a local laptop. (Ubuntu, Ruby 1.9.2, and Passenger 3.0.12.)

Used the deployment instructions in "Agile Web Development .... Rails", V4. The first simple application booted up w/o problem.

I then created a 2nd simple app with very similar characteristics. Edited /etc/apache2/apache2.conf with a second VirtualHost directive, and edited /etc/hosts to map the 2nd named URL to the same 127.0.0.1 address.

Restarting Apache blows up as shown below:

apache2: Syntax error on line 240 of /etc/apache2/apache2.conf: Cannot load /home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.12/ext/apache2/mod_passenger.so into server: /home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger 3.0.12/ext/apache2/mod_passenger.so: cannot open shared object file: No such file or directory

Both apps were bundled with Passenger. "locate mod_passenger.so" returns the correct location. Is there a better way to do this?

3
So what does the relevant it of apache2.conf look like?Frederick Cheung

3 Answers

0
votes

does the file

/home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.12/ext/apache2/mod_passenger.so

really exist and it's readable for apache?

0
votes

This is how i setup multiple virtualhosts with passenger:

user@debian:# cat /etc/apache2/mods-enabled/passenger.conf 
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
  PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby
</IfModule>

user@debian:# cat /etc/apache2/mods-enabled/passenger.load 
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so


user@debian:# cat /etc/apache2/sites-enabled/site1
<VirtualHost *:80>
  ServerName site1
  RailsEnv development

  DocumentRoot /var/www/site1/public
  <Directory /var/www/site1/public>
    Options None
    AllowOverride None

    Order deny,allow
    Allow from all
  </Directory>
</VirtualHost>


user@debian:# cat /etc/apache2/sites-enabled/site2
<VirtualHost *:80>
  ServerName site2
  RailsEnv development

  DocumentRoot /var/www/site2/public
  <Directory /var/www/site2/public>
    Options None
    AllowOverride None

    Order deny,allow
    Allow from all
  </Directory>
</VirtualHost>
0
votes

Surely.

For production, install rvm in system wide mode instead of user mode, by adding sudo to the install command. In development you can stay with user mode.

Install the passenger gem in the global gemset for your specified ruby. Do the same with gems that will be user by more than one application (remember version requirement for each gem)

after running the install apache-passenger-mod command in the server copy the resulting mod loading

Then to get the correct gemset to load add this file to your config folder

# setup_load_path.rb
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    # RVM.use_from_path! File.dirname(File.dirname(__FILE__))
    # edit this line according to you ruby version
    RVM.use!('1.9.2@YOUR_GEMSET')
  rescue LoadError
    # RVM is unavailable at this point.
   raise "RVM ruby lib is currently unavailable."
 end
end

# Select the correct item for which you use below.
# If you're not using bundler, remove it completely.
#
# # If we're using a Bundler 1.0 beta
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
#
# # Or Bundler 0.9...
# if File.exist?(".bundle/environment.rb")
#   require '.bundle/environment'
# else
#   require 'rubygems'
#   require 'bundler'
#   Bundler.setup
# end

After that just make apache point to the correct public directory

DocumentRoot /var/www/app/public
  <Directory /var/www/app/public>