Skip to content

Instantly share code, notes, and snippets.

@jakehow
Forked from joerichsen/CentOS Rails stack
Created October 22, 2008 05:47
Show Gist options
  • Save jakehow/18549 to your computer and use it in GitHub Desktop.
Save jakehow/18549 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Inspired by http://blog.fiveruns.com/2008/9/24/rails-automation-at-slicehost
apt-get update
apt-get upgrade -y
apt-get -y install build-essential libssl-dev libreadline5-dev zlib1g-dev
apt-get -y install mysql-server libmysqlclient15-dev mysql-client
apt-get -y install ruby ruby1.8-dev irb ri rdoc libopenssl-ruby1.8
RUBYGEMS="rubygems-1.3.0"
wget http://rubyforge.org/frs/download.php/43985/$RUBYGEMS.tgz
tar xzf $RUBYGEMS.tgz
cd $RUBYGEMS
ruby setup.rb
cd ..
# Install Ruby Enterprise Edition
wget http://rubyforge.org/frs/download.php/41040/ruby-enterprise-1.8.6-20080810.tar.gz
tar xvzf ruby-enterprise-1.8.6-20080810.tar.gz
yes '' | ./ruby-enterprise-1.8.6-20080810/installer
# Install Passenger
/usr/bin/gem1.8 install -v=2.0.3 passenger --no-rdoc --no-ri
apt-get -y install apache2-mpm-prefork apache2-prefork-dev
yes '' | passenger-install-apache2-module
# Create sample Rails app
/usr/bin/gem1.8 install rails --no-rdoc --no-ri
cd /var/www
rails -d mysql hello
cd hello
./script/generate controller welcome hello
echo "Hello World" > app/views/welcome/hello.html.erb
rake db:create RAILS_ENV=production
# Create the Apache2 Passenger module files
cat >> /etc/apache2/mods-available/passenger.load <<-EOF
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
EOF
cat >> /etc/apache2/mods-available/passenger.conf <<-EOF
<IfModule passenger_module>
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3
PassengerRuby /opt/ruby-enterprise-1.8.6-20080810/bin/ruby
</IfModule>
EOF
a2enmod passenger
# Create a site file for the sample Rails app
IP_ADDRESS=`ifconfig eth0 | sed -n 's/.*dr:\(.*\) Bc.*/\1/p'`
cat >> /etc/apache2/sites-available/hello <<-EOF
<VirtualHost $IP_ADDRESS:80>
ServerName www.yourhost.com
DocumentRoot /var/www/hello/public
</VirtualHost>
EOF
a2ensite hello
# That's it!
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment