Adding Rails/Passenger to Debian Using Ruby Gems

I needed to serve both static and Ruby on Rails (RoR) pages on my rubyat.com site running Debian gnu/Linux stable (lenny). The apt-get/Debian way is unsatisfactory, as, among other issues, Debian does not yet have Passenger in its stable (lenny) branch. After doing some research, and some trial and error, this is what worked for me.

1. Uninstall any gems. I’d installed  rake and Rails via Debian apt-get. Unfortunately, most Ruby gems aren’t available that way.

2. Uninstall rubygems via apt-get. Same logic.

3. Install ruby development headers.
sudo apt-get install ruby1.8-dev

4. Install rubygems from source. This gets me the newest version of rubygems, and also makes all future gems available.

sudo wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
sudo tar -xzvf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb

5. Install Rails.
sudo gem install rails (Installs the latest stable version of Rails. Today it is 2.3.8).

6. Install Passenger.
6a. Install the Passenger Ruby Gem.
sudo gem install passenger

6b. Install the Apache Passenger module.
sudo apt-get install apache2-prefork-dev
sudo apt-get install libapr1-dev (Note: already installed on my machine.)
sudo apt-get install libaprutil1-dev (Note: already installed on my machine.)
sudo passenger-install-apache2-module

6c. Edit my Apache configuration file. In Debian, this is /etc/apache2/apache2.conf.
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/bin/ruby1.8

Now, some of my web sites use an older version of rails. So:

7. Install older version of rails.
sudo gem install -v=2.1.0 rails

8. Restart Apache.
sudo /etc/init.d/apache2 restart

At this point, Ruby on Rails pages get served, but other content (such as this WordPress blog) does not.

9a. Edit my site Apache configuration.
sudo nano /etc/apache2/sites-available/mysite
inside <VirtualHost> add the following three lines:
<Location /blog>
PassengerEnabled off
</Location>

And these three lines:
<Location /mail>
PassengerEnabled off
</Location>

9b. Restart Apache.
sudo /etc/init.d/apache2 restart

9c. Test the configuration. Make sure everything works. For me, it does.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>