Skip to content

Instantly share code, notes, and snippets.

@mislav
Created December 6, 2008 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mislav/32917 to your computer and use it in GitHub Desktop.
Save mislav/32917 to your computer and use it in GitHub Desktop.
Apache2, Passenger & Ruby Enterprise Edition
set -e
RE="ruby-enterprise-1.8.6-20090520"
PREFIX=/opt/$RE
VERSION=2.2.2
GEM_PATH="$PREFIX/lib/ruby/gems/1.8/gems/passenger-$VERSION"
DOMAIN=example.com
APP_ROOT=/u/apps/$DOMAIN
# install Apache2
apt-get install -qq apache2 apache2-prefork-dev
# download and install REE
cd /tmp
wget http://rubyforge.org/frs/download.php/57097/$RE.tar.gz -O- | tar xz
$RE/installer -a $PREFIX | ruby -e 'while gets; print "."; $stdout.flush; end'
# install necessary gems (Rails is auto-installed)
cd $PREFIX
bin/gem install mislav-will_paginate mattetti-googlecharts ryanb-acts-as-list haml thoughtbot-paperclip
# install Passenger
bin/passenger-install-apache2-module -a
# set up Apache to load the new module
echo "LoadModule passenger_module $GEM_PATH/ext/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load
ln -s ../mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load
echo "PassengerRoot $GEM_PATH
PassengerRuby $PREFIX/bin/ruby" > /etc/apache2/mods-available/passenger.conf
ln -s ../mods-available/passenger.conf /etc/apache2/mods-enabled/passenger.conf
# mod_deflate
echo "<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml
</IfModule>" > /etc/apache2/mods-available/deflate.conf
ln -s ../mods-available/deflate.load /etc/apache2/mods-enabled/deflate.load
ln -s ../mods-available/deflate.conf /etc/apache2/mods-enabled/deflate.conf
# mod_rewrite
ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
# set up a virtual host
echo "<VirtualHost *:80>
ServerName www.$DOMAIN
ServerAlias $DOMAIN *.$DOMAIN
DocumentRoot $APP_ROOT/current/public
RailsEnv production
RailsAllowModRewrite on
<LocationMatch \"\.(js|css)$\">
SetOutputFilter DEFLATE
</LocationMatch>
</VirtualHost>" > /etc/apache2/sites-available/$DOMAIN
# link it up
rm -f /etc/apache2/sites-enabled/*
ln -s ../sites-available/$DOMAIN /etc/apache2/sites-enabled/$DOMAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment