Engineering a Software Startup


Setting up Ubuntu Linux For Ruby On Rails Development

Posted in Development, Technical by Rajeev Kalavar on the December 9, 2007
Tags: , , , , , , , , , , , , , , ,

If you are planning on installing Ubuntu and setting it up for development but don’t know where to look, you’re in luck. Sometime back, I went through the trouble of installing a fresh Ubuntu7.0.4 (Fiesty Fawn)  in a VMWare slice and setting it up for some Rails development. I’d never worked with Ubuntu before, so I googled for help. And as always, I found a ton of crap mixed with a few nuggets of gold.

Good luck finding all the information you want in one document! I spent a whole weekend trying to mine the right information on the development stack and tools I needed. There are some good tutorials out there, but each deals with a specific task and you have to go through a fair set of links before you find the one for a particular topic that makes sense. 

Took a bit of time, but eventually I got the environment I wanted and I was ready to rumble. I was keen on writing an uber-tutorial with all that I had learned to share on my blog, but that would have required some serious effort and time commitments at my end. Effort, no problem, but time, hmm… with 2 jobs, a blog and a baby on the way, that’s a luxury I just didn’t have. The next best option was to share the notes I had jotted down as I went through this process. So here it is – a collection of the steps I took during the install process (in sequence) with links to the articles on-line that I found very useful.

The task:

To set up a development environment (run-time and related tools) for developing Ruby On Rails and Java applications on a Ubuntu Linux Operating System.

Why Ubuntu:

Most in the Rails community either develop on Linux or Mac. I’ve almost never come across anybody who deploys Rails on a Windows setup in a production environment. By choosing Ruby On Rails as our technology stack, it was clear I’d need to start working with a Linux based development environment.

There are many different operating systems based on GNU/Linux: Debian, SuSE, Gentoo, RedHat, etc. Of the distros I researched, Debian seemed to be the flavor of choice for the relative newcomers to the Linux world. Debian has a powerful application packaging tool (named apt-get) that allows you to easily (and painlessly) install software, which has been Debian’s major claim to fame. Ubuntu is an offspring from the Debian distro that’s had a meteoric rise in the open source community primarily because of it’s Debian lineage, but more importantly because they make it super easy to install and use (they’ll even mail you a CD free of cost if you don’t want to download an ISO image and burn one for yourself). And because it’s based on Debian, it inherently supports the apt-get packaging tool. It also has a well defined 6 month release cycle, so it’s a stable and well-maintained platform.

Easy to install, easy to use, and the community was raving about it. I decided to jump on to the Ubuntu bandwagon as well!

Steps: 

Installing Ubuntu7 (Fiesty Fawn)

  1. Download and create the CD
  2. Install via the CD.

References:  http://www.ubuntu.com/getubuntu

Installing the Lamp Stack

1) Download and install packages using apt-get
$> sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
2) Check Status of PHP – Edit file phpinfo.php in Apache web-root and test
$> sudo vim /var/www/phpinfo.php
3) Navigate to http://localhost/phpinfo.php- ensure php info is available.
 

References:
http://www.ossgeeks.co.uk/?p=15
http://www.ctunion.com/node/22

Installing PhpMyAdmin

1) Download and install phpMyAdmin mysql webclient. This is also available through apt-get
$> sudo apt-get install phpmyadmin
2) Ensure phpmyadmin can work with the mysql database. Navigate to /var/www/phpmyadmin/config and edit config.inc.php
$> sudo gedit /var/www/phpmyadmin/config/config.inc.php
Change
$cfg['Servers'][$i]['auth_type'] = ‘cookie’;
To
$cfg['Servers'][$i]['auth_type'] = ‘config’;
Add
$cfg['Servers'][$i]['username'] = ‘<sql uname>’;
$cfg['Servers'][$i]['password'] = ‘<password>’;
3) Navigate to phpmyadmin webclient and test: http://localhost/phpmyadmin

IP information if you don’t want localhost

$> ifconfig

Installing Java

1) Install the package java-package, from contrib:
$> apt-get install java-package
2) Download the Sun JDK installer for Linux, from http://java.sun.com/j2se/. Had to download 1.5 because the following steps did not work for Java6 (sept 8, 07)
3) Create the Debian package. Be sure you are not root:
$> fakeroot make-jpkg jdk-1_5_0_12-linux-i586.bin
(change to the name of your downloaded archive)
4) Install the Debian package. Become root and run this:
$> dpkg -i sun-j2sdk1.5-1_5_12+update01.deb
 

References:
http://wiki.serios.net/wiki/Debian_Java_JRE/JDK_installation_with_java-package
http://www.cosy.sbg.ac.at/~amayer/files/How-to-install-Java-on-Debian.html

Installing eclipse

1) Download the eclipse ‘classic’ (or any other) package from http://www.eclipse.org/downloads/
2) Copy eclipse-SDK-3.3-linux-gtk.tar.gz to /usr/bin (folder where you’ll extract eclipse)
$> su
$> cp eclipse-SDK-3.3-linux-gtk.tar.gz /usr/bin
3) Extract the tar – an eclipse directory will be created
$> cd /usr/bin
$> tar -xzvf eclipse-SDK-3.3-linux-gtk.tar.gz

$> exit
4) Launch eclipse
$> /usr/bin/eclipse/eclipse &
5)) Install RDT For Eclipse & Installing RadRails For Eclipse: Follow http://www.oreillynet.com/pub/a/ruby/2007/04/26/ruby-on-rails-meets-eclipse.html

References:
http://www.fluggart.com/linux/general/eclipse.html

http://www.oreillynet.com/pub/a/ruby/2007/04/26/ruby-on-rails-meets-eclipse.html

Installing Subversion

1) Download and install subversion
$> sudo apt-get install subversion
2) Checkout the rails project from your repository

$> svn co svn:<your repository>

Installing KDE – Not Successful

$> sudo aptitude update && sudo aptitude install kubuntu-desktop

References: (also explains removing, switching to Gnome, etc)
http://www.psychocats.net/ubuntu/kde

Installing Ruby On Rails

1) Download and install ruby, gems and dependencies
$> sudo apt-get install ruby rubygems irb ri rdoc ruby1.8-dev build-essential
2) Next, install rails through gems
$> $ sudo gem install rails –include-dependencies
3) There are a few more steps. See reference.
3.5) Install sql driver for ruby
$> sudo apt-get install libmysql-ruby
4) Install dependent gems (see reference for rmagick)

References:
http://wiki.rubyonrails.org/rails/pages/RailsOnUbuntu

Installing Mozilla Thunderbird

$> sudo aptitude install mozilla-thunderbird
2) If you want to open the application go to Applications -> Internet -> Thunderbird Mail Client
3) Finally, configure the client with your POP3 and SMTP server settings

Installing FTP Service

1) Download and install
$> sudo apt-get install proftpd
2) During install, set option to standalone (if you don’t have inetd function)
3) To Restart
$> sudo /etc/init.d/proftpd restart

References:
Setting up ftp service: http://ubuntuguide.org/wiki/Ubuntu:Feisty#FTP_Server
If inetd doesn’t work http://ubuntuforums.org/archive/index.php/t-79588.html

Install MySQL Graphical tools

Application->Add/Remove->Programming->MySQL Administrator, Query Browser, RapidSVN
   >Internet->Filezilla

Install SSH

For Capistrano (preferred way to deploy a Rails application) to work, you need ssh enabled on your server, and an SSH client on your development box.

http://www.nukesilo.com/2007/03/08/installing-openssh-on-ubuntu-linux-ssh-part-1/
putty:
http://www.chiark.greenend.org.uk/~sgtatham/putty/

P.S: 

Hope you found this useful:) Please do add a comment if you have additional useful pointers to share… it would be great if this post could grow into a ‘living’ list of things one could do to build a kick-ass Ubuntu Rails setup.

5 Responses to 'Setting up Ubuntu Linux For Ruby On Rails Development'

Subscribe to comments with RSS or TrackBack to 'Setting up Ubuntu Linux For Ruby On Rails Development'.

  1. Dawoud said,

    The tut is good, i’m using ubuntu Gutsy Gibbon – a lot of the stuff was included in Synaptics package manager so I’ve had a real smooth ride so far, I’d have liked to know why you included certain packages – being a noob its not all so clear, not that its important (I could of course follow your links tho!), it’d save an hour of my time, probably cost 20 mins of yours tho. Thanks again.

  2. Rajeev Kalavar said,

    If you could be a bit more specific on the packages, I’d probably give a better answer, but in my case, I wanted the RoR and Java stack; you can skip either if you don’t work on that particular technology.

    PhPMyAdmin is nice-to-have. Gives you webaccess, but I primarily installed it because i wanted to check it out. With some of the GUI sql tools that I listed later, you can ignore this. Same with php – if you don’t need it, you can ignore…

  3. Paul said,

    $> sudo /etc/init.d/apache2 restart

    Right before testing php and apache. It didn’t pick it up right after the vanila install.

    Thanks a bunch for the compilation, I’m running through the whole thing, and will let you know as things progress. I’m building of top of this VMware image, for quick Ruby dev environment deployment. (Java and Eclipse already installed). I’m thinking Aptana. Other Ruby tools I should look at? I’ve never railed before.

    http://jars.de/linux/ubuntu-804-vmware-image-download

  4. Paul said,

    Ok, so on Ubuntu 8.04 – the VMware image I’m setting up for Ruby development,

    phpmyadmin ends up in /usr/share/phpmyadmin

    $> sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

    also, on this page, the quotes around
    $cfg['Servers'][$i]['username'] = ‘’;
    $cfg['Servers'][$i]['password'] = ‘’;

    are not the rightones, ‘ is different from ‘ and ’, but maybe you did that on purpose? :-)

    Cool, moving on.


  5. Paul: I don’t see it necessary to create the symbolic link between /var/www/phpmyadmin and /usr/share/phpmyadmin. It’s good information to know that phpmyadmin actually end up in /usr/share instead of in /var/www, but take a look in this Apache configuration file /etc/apache2/conf.d/phpmyadmin.conf (a symbolic link to /etc/phpmyadmin/apache.conf) where this line “Alias /phpmyadmin /usr/share/phpmyadmin” will take care of the “linking” for Apache, so it can actually serve you the phpmyadmin application.


Leave a Reply