Like what you're reading? Want to get rid of ads? Donate some BTC and help me stop relying on AdSense. BTC Address: 1E4TGB9e4mwfUusg4XHnte1Szi1gDFWDd9

Set Up a Powerful Development Environment in Ubuntu 12.04 Fast

Today is my one year anniversary at my current job. When I was hired as a developer I thought I’d get my choice of Windows, Mac, or Linux environments. I think I got my hopes up a little on that one. I got stuck with a Windows machine. Fortunately for me, I’m adaptable so I made do with what I got and carried on. I spent my first day configuring my machine with all the goodies I needed to be an efficient web developer. Now it’s exactly one year later and I’m back at it again. I’m working on a new project and working with Linux would make things much easier. I got my wish and now have a brand new Ubuntu 12.04 installed alongside my old Windows.

I have to get up and running quickly however. I have about two hours before people will start wondering what the hell I’m doing over here so I’ve documented the process of setting up my development environment with all of the standard tools and some newer toys too that most web developers would likely be using. So I’m going to share my process for how to set up a development environment quickly on Ubuntu partly as a way of helping others but mostly as a note to myself for future reference. This setup includes a basic LAMP stack, version control tools, NodeJS, and more…

Get your server up first

First thing I do is install a local server for development. Sometimes I’m developing for Rails or with Node but when I’m not, it’s always useful to have an AMP stack running in the background.

Apache, MySQL, PHP

sudo apt-get install apache2

Boom! Apache on your computer. Now make sure your document root is where you want it and has the right permissions for all users of the system to read and write. Apache will usually put its document root in /var/www. In production I like my sites in /srv/www but in development I want it in ~/Sites. So I create a symlink from my desired folder so /var/www. You’ll need to rename the www folder first for this to work.

Then restart Apache when you’ve got it how you like it with sudo service apache2 restart

MariaDB is the new hotness right now when it comes to MySQL replacements. Apparently it’s literally a drop-in replacement with no need to jump through hoops but since I’ve never actually installed it before I’m just going to show you how to get MySQL 5.

Run sudo apt-get install mysql-server and give the root user a password when prompted.

In production you’d also subsequently run sudo mysql_secure_installation but I feel this is optional on a development machine only used by you.

For PHP you’ll need a few packages. Just run sudo apt-get install php5 php-pear php5-mysql.

Version control

If you’re anything like me you make heavy use of Git for version control and deployment of smaller sites. Git needs a few packages first so make sure to run and install these first: sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev.

Then just sudo apt-get install git git-core.


You’ll also want RVM and NodeJS. So, here’s the deal with those – don’t use your system’s package manager to install them. Those packages are out of date most of the time. Get them from source.


RVM doesn’t seem very handy at first, especially if you’re new to Ruby development, but it may save you a lot of trouble in the future so its worth having. Even if you never use any of its features its still helpful – it’ll never get in your way and you’ll eventually come across a situation where you need a specific version of Ruby and a specific collection of Gems.

Run \curl -L | bash to install RVM. Do not use sudo and RVM together!

Once you’ve got it installed you may either need to reload your .bashrc, .bash_profile, run rvm reload, or quit and reopen your terminal. I can never figure out which is needed and a lot of times none of that is. It all depends on how you’ve set up your system thus far. One thing to note is that on Ubuntu 12.04, if you’re using the default terminal emulator then you’ll need to check the box in your preferences that says something to the effect of “Use this as a login shell” for RVM to not complain at you. Using Terminator or other terminals may not have this problem and thus you won’t have to do anything. In any case, RVM will actually instruct you on what you need to do when you run the install or any RVM-specific command.

So now you’ll want some Rubies. I’d get 1.9.3 and 2.0.0. Version 1.8.7 is officially retired now will become increasingly less useful. So to install any version of Ruby with RVM run the following:

rvm list # Will show you a list of installed Rubies
rvm install 1.9.3 # Installs Ruby 1.9.3

At this point, its important to note the install syntax. In the example I just gave a version number but you can be very specific about what version of Ruby you want installed all the way down to the patch. So you could run rvm install ruby-1.9.3-p247 to get that specific version at that specific patch. This usually isn’t necessary but I have run into the situation when developing a Rails app on multiple machines that had the same Ruby version but different patch numbers. RVM complained about not having the right Ruby version based on my .rvmrc file. But anyway, back to isntallation.

For Ruby 2 you’ll want to run rvm install 2.0.0. If your RVM is up to date you’ll automatically get the very latest patch of the version of Ruby you requested using this method. To start using any one version of Ruby run rvm use 1.9.3 (replace with your preferred Ruby version number). To have RVM default to a certain version of Ruby unless instructed otherwise you’ll run rvm use --default x.x.x where “x.x.x” is the version you want.

Node and NVM

Node is now in a similar situation as Ruby with how fast it changes so some smart person created NVM, which is very much the same idea as RVM except for NodeJS. So skip getting Node altogether and get NVM instead.

To install NVM run curl | sh

To install a specific version of Node run nvm install 0.10 for the latest 0.10 release or any other specific version like nvm install 0.8.9. To use a specific version of Node once installed in any directory you just run nvm use 0.8.9 (or whatever version you want) just like you’d do with RVM. The NVM readme on GitHub has more information if you need it.

And more…

That was a lie. I’ll be honest. I started writing this post over a month ago and now I forgot where I was going with it. Hopefully what’s here is helpful though.

Web development

« Perspective Greek Coffee »