Tuesday, October 30, 2012

Ubuntu 12.04 LTS Developer Workstation Setup for Ruby on Rails + PostgreSQL Development

I'm often asked which environment I like to do development on. The question is of course "it depends". Specifically for Ruby on Rails, I like using Ubuntu 12.04 LTS and Linux simply because I actually deploy to Linux in production environments, so when I develop I like to mirror production environments as much as possible. Many people like using a Mac but I personally only do Ruby / Rails Development on my Mac when I'm travelling.

The setup below I actually provision inside a VMWare Workstation 8 or 9 machine and provision about 8GB of memory to the virtual machine. My workstations (I have a few of them, R5400's, T5400 and T5500's) I use are Dell Precisions and the hardware usually consists of Dual Quad Core Xeon's with a minimum of 16GB to 32GB of memory and run Windows 7 (though Windows 8 we are testing as well).

I actually like using Titanium Studio from Appcelerator since we use that for iOS / Android development and also for Ruby on Rails. It's a great IDE since it's based on Eclipse so it seems to work quite well on Mac, Windows and Linux. It's the IDE we've standardized on for Cross Platform development.

Installation and Packages
sudo apt-get update
sudo apt-get -y upgrade

sudo apt-get install -y build-essential bison openssl curl git-core zlib1g zlib1g-dev screen libruby libcurl4-openssl-dev libssl-dev mysql-server mysql-client libmysqlclient-dev libxml2-dev  libxslt1-dev vim nodejs ssh gedit libreadline-gplv2-dev automake libjpeg62

sudo apt-get -y install build-essential git-core curl libssl-dev \
                 libreadline6 libreadline6-dev \
                 zlib1g zlib1g-dev \
                 libmysqlclient-dev \
                 libcurl4-openssl-dev \
                 libxslt-dev libxml2-dev

Password for MySQL used in VM is password
GNOME Extensions

sudo add-apt-repository ppa:ferramroberto/gnome3
sudo apt-get update
sudo apt-get install gnome-shell-extensions-common -y

sudo apt-get install gnome-shell-extensions-system-monitor -y

sudo apt-get install gnome-shell-extensions-apps-menu -y

Application Indicators and System Monitors


sudo add-apt-repository ppa:indicator-multiload/stable-daily
sudo apt-get update
sudo apt-get install indicator-multiload

Installing Google Chrome

Open of firefox and Download google chrome from Google www.google.com/chrome
Installing Java 7 and Java 6
#oracle java 7
sudo apt-get install openjdk-7-jre

#java 6  (Android SDK works better with Java 6)
mkdir ~/src
cd ~/src
git clone https://github.com/flexiondotorg/oab-java6.git
cd ~/src/oab-java6
sudo ./oab-java.sh

You can follow the installation process with:
tail -f ~/src/oab-java6/oab-java.sh.log

sudo apt-get install sun-java6-jdk sun-java6-plugin -y

put these in the ~/.bashrc file
export EDITOR=vim
export JAVA_HOME="/usr/lib/jvm/java-6-sun"
export JAVA="$JAVA_HOME/jre/bin/java"


sudo apt-get install postgresql pgadmin3
sudo apt-get install postgresql-server-dev-9.1


1) To connect to PostgreSQL from a remote machine modify the

sudo gedit /etc/postgresql/9.1/main/postgresql.conf

change the line

listen_addresses = 'localhost'


listen_addresses = ''

exit the file

Change the default postgres user name

sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'postgres';

2) modify the following file
sudo gedit /etc/postgresql/9.1/main/pg_hba.conf

Add the line

local   all         all                         md5
host   all    all        md5

Start / Stop / Restart PostgreSQL

sudo /etc/init.d/postgresql restart


Click on the Dash Home, then type PGAdmin open that up and connect to postgresql
Ruby on Rails
Option 1 - rubyenv / rbenv
Make sure you are logged in as root or do an su

git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv

# Add rbenv to the path:
echo '# rbenv setup' > /etc/profile.d/rbenv.sh
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh

chmod +x /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh

# Install ruby-build:
pushd /tmp
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build

# Install Ruby 1.9.3-p194:
rbenv install 1.9.3-p194
rbenv global 1.9.3-p194

# Rehash:
rbenv rehash

sudo -i

gem update
gem install rails
gem install pg
gem install mysql2
gem install mongo

Titanium Studio

extract the titanium studio

cd ~/Downloads
unzip titanium.linux.gtk.x86.zip
mkdir ~/Applications
mv Titanium\ Studio/* ~/Applications/Titanium\ Studio

Don’t save the login, there seems to be a bug with titanium if you do. If you have problems logging in be sure to remove the  ~/.eclipse directory from the home directory
If Titanium hangs at login


User Management and Administration

Add a new User
The following adds a new standard user without admin privileges. Be sure to add the user as an administrator if you want to be able to execute sudo

adduser {username}

Password Change
passwd {username}

Adding a User to the Sudo group
usermod -a -G sudo {username}

Changinging the Computer

sudo gedit /etc/hostname

Path To Rails


No comments: