RSS
 

Installing Ruby on Rails on Ubuntu 10.04 with speedtrain

31 Jul

[Update 3/7/2011] Check the updated version of the speedtrain script for Ruby 1.9.2 and Rails 3 here:http://obi-akubue.org/?p=922 and https://github.com/obi-a/speedtrain.

I wrote a small user friendly script that installs Ruby on Rails on Ubuntu 10.04. This script installs Ruby,Rubygems, Rails and sqlite. It also creates a sample Rails App.

Usage:

To install Ruby on Rails on Ubuntu 10.04 with this script, using command line.

Step 1: Download the script.

wget http://whisperservers.com/speedtrain

The script is called speedtrain.

Step 2. Make the script executable

chmod +x speedtrain

Step 3. Run the script

./speedtrain

The script will install Ruby,RubyGems, Rails and sqlite. It will then create a folder in your $HOME directory (~/rails_app/) called rails_apps. This is the folder where you store the rails apps you create. The script will also create a sample Rails App. The sample app is located at ~/rails_app/testapp.

To run the sample Rails app. Type…
cd ~/rails_apps/testapp
ruby script/server

Open the browser and type http://localhost:3000/

Source code for the speedtrain shell script.

#!/bin/bash
#:Title   :Speedtrain on Rails
#:Date    :
#:Author  :Obi Akubue
#:Version :0.0
#:Description: This script installs Ruby on Rails on Ubuntu 10.04. (It installs ruby,rubygems,rails,sqlite and creates a test rails app)
 #Notable credits: http://ascarter.net/2010/05/10/rails-development-on-ubuntu-10.04.html (helped me resolve conflicts with rubygems and debian package manager)
 
red='\e[0;31m'
RED='\e[1;31m'
blue='\e[0;34m'
BLUE='\e[1;34m' #light blue
cyan='\e[0;36m'
CYAN='\e[1;36m'
GREEN='\e[1;32m'
NC='\e[0m' # No Color
 
echo  -e "${GREEN} Welcome to Speedtrain on Rails"
echo "Installing Rails..."
echo "This will take a few minutes to complete.."
 
echo -e "${RED} updating system..."
echo -e "${CYAN}"
sudo aptitude update
 
echo -e "${RED} installing ruby..."
echo -e "${GREEN}"
sudo apt-get install irb libopenssl-ruby libreadline-ruby rdoc ri ruby ruby-dev
 
echo -e "${RED} installing rubygems..."
echo -e "${CYAN}"
cd /usr/local/src
sudo wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz
sudo tar xzvf rubygems-1.3.6.tgz
cd rubygems-1.3.6
sudo ruby setup.rb
 
echo -e "${RED} updating rubygems..."
echo -e "${GREEN}"
sudo update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.8 1
sudo gem update --system
 
echo -e "${RED} installing rails..."
echo -e "${CYAN}"
sudo gem install rails
 
echo -e "${RED} installing sqlite..."
echo -e "${GREEN}"
sudo apt-get install libsqlite3-dev sqlite3 sqlite3-doc
sudo gem install sqlite3-ruby
 
echo -e "${RED} creating dev directory..."
echo -e "${CYAN}"
mkdir ~/rails_apps/
 
cd ~/rails_apps/
echo -e "${RED} creating dev test app..."
echo -e "${GREEN}"
rails testapp
 
echo -e "${GREEN}"
echo "Rails has been successfully installed"
printf "We created a test Rails App for you at ~/rails_apps/testapp/\n"
printf "To run the test App type\n"
echo -e "${CYAN} cd ~/rails_apps/testapp\n"
echo "ruby script/server"
echo -e "${NC}"
 
 

Tags: , , ,

  • Great post. Thanks for providing the script and the code. It is really useful.

    • Obi

      Awesome. I am happy you found it useful.

 
Premium Wordpress Plugin