• Setting Up Ubuntu for Rails Development

    These are a the procedures we use to setup a PC or VM for development of a ruby on rails application.

    First things first, get your install software ready.  These instructions are based on the Hardy Heron version of Ubuntu (8.04).

    Install the base OS and then fire up the terminal so you can copy and paste the following commands. 

    So once you have the base installed, make sure your distribution is up to date:

    sudo apt-get update
    sudo apt-get dist-upgrade

    Now install the package required for building software:

    sudo apt-get install build-essential

    Now we are going to install Ruby and Mysql:

    sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 psmisc

    Now download the latest rubygems, we like to build this so that we have the latest version since the package repositories for Ubuntu have an older version:

    wget https://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
    tar -xzvf rubygems-1.3.1.tgz
    sudo ruby setup.rb

    Now make sure the symbolic links are all set. If you have to type gem1.8 list (instead of just gem list) then the link is not working:

    sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
    sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
    sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
    sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
    sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

    Now install rails:

    sudo gem install rails

    Having setup the environment, you now need to install something to develop with. We like to use Netbeans for this (but we do NOT use Jruby).

    Download the install script for the latest Netbeans. I usually just download this to the desktop, then run it without sudo since we want to make sure the local user has full control. Do NOT install it outside of the user’s home directory!

    wget ftp://ftp.ussg.iu.edu/netbeans/6.5/bundles/netbeans-6.5-ml-ruby-linux.sh

    Once installed, you need to configure netbeans to not use Jruby. Go into the Netbeans menu, under Tools and select RubyGems. Make sure you set the default gems to NOT use Jruby. If you wish, just remove Jruby from netbeans, then you do not need to worry about the wrong set of gems being used.

    If you wish to install ImageMagick so you can use the Rmagick gem, do the following:

    Remove old imagemagick package:

    sudo apt-get remove imagemagick

    Remove old graphicsmagick:

    sudo apt-get remove graphicsmagick

    Install the build tools:

    sudo apt-get install build-essential

    Install build dependencies for ImageMagick:

    sudo apt-get build-dep imagemagick

    Now make sure you have everything else you will need:

    sudo apt-get install  libperl-dev libperl gcc libjpeg62-dev libbz2-dev libtiff4-dev libwmf-dev libz-dev libpng12-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev liblcms1-dev libexif-dev perl libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config

    Download ImageMagick, extract it and switch to it:

    sudo wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.4.8-5.tar.gz
    sudo tar xvzf ImageMagick-6.4.8-5.tar.gz
    cd ImageMagick-6.4.8-5/ 

    sudo ./configure --disable-openmp
    sudo make
    sudo make install

    To confirm it all worked and see available formats, run the following:

    identify -list format

    We had to execute and add the following to the .bashrc file in order to get it working after an error with the above:

    export LD_LIBRARY_PATH=/usr/local/lib

    Now to install the Mysql gem to improve Mysql performance. You need to get the proper headers to install the gem:

    sudo apt-get install libmysqlclient-dev 

    sudo gem install mysql --no-rdoc --no-ri


    Leave a reply