Skip to content

Instantly share code, notes, and snippets.

@bradmontgomery
Created January 10, 2012 04:45
Show Gist options
  • Save bradmontgomery/1587015 to your computer and use it in GitHub Desktop.
Save bradmontgomery/1587015 to your computer and use it in GitHub Desktop.
RVM + Apache + passenger setup for Ubuntu
# Install rvm system-wide
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib
rvm pkg install openssl
# install the latest ruby (and make it the default)
rvm install 1.9.3
rvm 1.9.3 --default
# install the passenger gem
gem install passenger
# Try installing the apache module and watch it fail (no apache, yet)
passenger-install-apache2-module
# Install the following required packages (as per passenger's instructions)
apt-get install libcurl4-openssl-dev libssl-dev zlib1g-dev apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev
# Create /etc/apache2/mods-available/passenger.load and include:
cat >> /etc/apache2/mods-available/passenger.load <<END_CONF
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
END_CONF
# Then create /etc/apache2/mods-available/passenger.conf
cat >> /etc/apache2/mods-available/passenger.conf <<END_CONF
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p0/ruby
END_CONF
# Symlink passenger.conf and passenger.load to /etc/apache2/mods-enabled/
cd /etc/apache2/mods-enabled
ln -s ../mods-available/passenger.conf .
ln -s ../mods-available/passenger.load .
# Update your app's apache config in /etc/apache2/sites-available/appname with something similar to the following:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/user/appname/public
<Directory /home/user/appname/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
# Then symlink this file from /etc/apache2/sites-enabled and reload apache:
cd /etc/apache2/sites-enabled
ln -s ../sites-available/appname .
/etc/init.d/apache2 reload
@mdpatrick
Copy link

Small world. Google turned this up for a search I did and it happened to be just what I needed. Thanks for the cliff's notes, Brad. :)

@geodis
Copy link

geodis commented Jan 6, 2014

Excelent!!

@neonmate
Copy link

Note for passenger-4.0.45:
The load path is now in /usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.45/buildout/apache2/mod_passenger.so .

@andrecunha
Copy link

This is excellent! Thank you very much for taking time to do this. It really helped me here. Thanks a lot!

@kksudo
Copy link

kksudo commented Sep 9, 2018

Thank you so much! You are best )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment