1
votes

I am using Ubuntu 10.04 on linode, and I have installed apache2 and Rails 3.2.2. My application works fine on example.com:3000

I have followed the instructions to install Phusion passenger here:

http://www.modrails.com/install.html

and here:

http://wiki.brightbox.co.uk/docs:rvm

But I am not sure how to actually run my application on example.com in production mode. What is the command I type in to do this? Do I do 'rails server' or 'rails server -p 80'? What is the command I use?

EDIT 1:

My Virtualhost file is located in

<VirtualHost *:80>
 ServerAdmin [email protected]
 ServerName example.com
 ServerAlias www.example.com
 DocumentRoot /srv/www/example.com/public_html/
 ErrorLog /srv/www/example.com/logs/error.log
 CustomLog /srv/www/example.com/logs/access.log combined

 <Directory /srv/www/example.com/public_html/>
    AllowOverride all
    Options -Multiviews
 </Directory>
</VirtualHost>

One thing I am not sure of is whether I should have the directory as

/srv/www/example.com/public_html/

/srv/www/example.com/public/

The linode installation guide stated the first method (http://library.linode.com/web-servers/apache/installation/ubuntu-10.04-lucid), but Passenger states the second. Does it matter as long as it is consistent?

My passenger module bits are as follows in /etc/apache2/mods-available:

in passenger.conf

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

in passenger.load

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so    

EDIT 2: I have now added the passenger module bits to the apache configuration file instead of the passenger.conf and passenger.load files. And I set the following for this to work:

config/environments/production.rb ... config.assets.compile = true ...

1

1 Answers

1
votes

The install process (eg, the passenger-install-apache2-module part) gives instructions at the end as to what you need to do.

The gist is to make a virtual host for the app in, say, /etc/apache2/sites-available/myapp that looks something like this:

<VirtualHost *:80>
  ServerName example.com
  ServerAlias *.example.com
  DocumentRoot /path/to/app/public

  PassengerMinInstances 2
  PassengerPoolIdleTime 600
  PassengerUserSwitching on
  PassengerDefaultUser someuser

  RailsBaseURI /

  <Directory "/path/to/app/public">
    FileETag none
    Options All
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Make sure you put the passenger module bits in the proper place as per the instructions. Here's what mine looks like:

$ cat /etc/apache2/mods-available/passenger.*
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11
PassengerRuby /usr/local/bin/ruby

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/mod_passenger.so

Then you just do the usual apache stuff:

sudo a2ensite myapp
sudo /etc/init.d/apache2 reload

Assuming example.com points to this machine, you should be good to go.