Created
February 2, 2009 05:57
-
-
Save jrimmer/56797 to your computer and use it in GitHub Desktop.
Fixed bad carriage returns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by http://blog.fiveruns.com/2008/9/24/rails-automation-at-slicehost | |
# | |
# This is a fork of: http://gist.github.com/16225 | |
# | |
# To it I've added: | |
# - Installation of the MySQL gem which is no longer included with Rails | |
# - A switch from Passenger 2.0.3 (specified in the original script) to 2.0.6 | |
# - Explanatory text at the end of the script to help the user understand | |
# what to do next. | |
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.1" | |
wget http://rubyforge.org/frs/download.php/45905/$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.6 passenger --no-rdoc --no-ri | |
apt-get -y install apache2-mpm-prefork apache2-prefork-dev | |
yes '' | passenger-install-apache2-module | |
# Install MySQL gem (no longer bundled w/ Rails) | |
/usr/bin/gem1.8 install mysql | |
# 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.6/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.6 | |
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 | |
# Instruct the user where to go from here. | |
echo "Setup appears to be complete, but it isn't quite finished yet." | |
echo "" | |
echo "The example site was created in /var/www/hello. Edit the database.yml" | |
echo "file in the /var/www/hello/config directory to have the password you" | |
echo "assigned to the root account for MySQL. Then run the command" | |
echo "rake db:create:all to create the databases needed for the example site." | |
echo "After that you can point your browser at $IPADDRESS/welcome/hello to" | |
echo "see a sample page." | |
read -p "Hit <return> or <enter> to reboot" | |
# That's it! | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment