Set up Linux box in VirtualBox for Ruby/Rails development

These notes were used on a Windows 7 machine to create an Ubuntu Server and started with the notes created by who started this after discovering my Vagrant notes didn’t quite get him where he wanted to be with Ruby and Rails development. I started with those and then added more parts as I was doing this behind the proxy and wanted any student to be able to copy what I’ve done to tweak their own version of a Linux box. I also referred to for general creating vm and for ubuntu server ISO.

I rebuilt the server in August 2015 and these notes were updated then.

We use a ‘server’ and not a ‘desktop’ ISO so that this is a smaller installation. Hence we only use a lightweight ‘desktop’ like Fluxbox. We still can use our Windows desktop, so we only need lightweight tools for this virtuarl machine.

Start with ISO

Once you have an ISO you can start it up and install it into VirtualBox.  You will need to set the proxy if at the university so that you can download more software as needed in the box. Just follow the defaults for the most part and let it use the whole partition. Set yourself easy username and password. This is a virtual machine remember so you don’t need to be paranoid. You can also tell it to install Postgresql during this phase too.

When the installation is done and you’ve logged back in again with your new account you can start adding the software you want to use for the application.

(No longer necessary for Aberdeen, but kept here in case you’re doing this somewhere else.) I found you need to set the proxy again for the session with the command:
export https_proxy=

If you need to set the root password then look at and at at end of page for running as su with root

This setup uses fluxbox as a lightweight desktop (right-click) for any options. You start the ‘desktop’ from the command line with ‘startx’ command and can right-click for menu options. When you’re done you drop out of the desktop with ‘right-click->exit’.
You can stop the virtual machine with ‘machine->Close and select ‘send Shutdown signal’ ‘so that pick up where left off before.

Installing the system

sudo apt-get update
sudo apt-get install xinit
sudo apt-get install fluxbox
sudo apt-get install build-essential
#Node.js Rails will not run without a Javascript Engine
sudo apt-get install python-software-properties

#might not need next two steps, try setting proxy first, but may need to also run this as su and thus set password for root. Try to avoid that though.
#set password for su
#switch to su and add proxy details so that su knows them.
export http_proxy=

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

#imagemagick so that we can manipulate images on the server
sudo apt-get install imagemagick libmagick++-dev

sudo apt-get install sqlite3 libsqlite3-dev

#Postgres <<– you need this for working with Heroku
sudo apt-get install libpq-dev (you may get some errors and also need to run sudo apt-get update to fix things, persist, it should all work)

We use the details at this Set up Ruby page to set up what we need on our Ubuntu server

#Git for version control
We’ll need version control and for dealing with some installation issues
sudo apt-get install git

We use the Rails details at this Set up Ruby page to set up what we need on our Ubuntu server

sudo apt-get install libxml2-dev libxslt-dev (cucumber/nokogiri)
sudo gem install rails –http-proxy
sudo gem install sqlite3 –http-proxy

sudo gem install rspec –http-proxy
sudo gem install rspec-rails –http-proxy

sudo gem install cucumber –http-proxy
sudo gem install cucumber-rails –http-proxy
sudo gem install capybara –http-proxy

sudo gem install rmagick –http-proxy

#Heroku tools for deploying to remote server
heroku toolbelt wget -qO- | sh (note capital letter ‘o’)

#rails new cookbook -T (t flag keeps tests out)
#cd cookbook
#bundle install will get the rest of the gems

##Other Programs
#Terminator (Better terminal)
sudo apt-get install terminator
#scite for editing files
sudo apt-get install scite

#Google Chrome (web Browser) – that is a capital ‘oh’ NOT a zero in command and each ‘sudo’ is a new command
sudo wget -q -O – | sudo apt-key add –
sudo sh -c ‘echo “deb stable main” >> /etc/apt/sources.list.d/google.list’
sudo apt-get update
sudo apt-get install google-chrome-stable

#sqlitebrowser (SQLite3 browser)
sudo apt-get install sqlitebrowser

#enable shared folders on machine
Start here for basics
This page has the scripts for mounting and running the install script
And then follow on with this post to configure integration

#change permissions on shared folder so default user can use this folder and edit files (edit in Windows on and run commands in Linux)
use this to add ruby to vboxsf folder permissions
sudo adduser xxxxxxx vboxsf
#need to log out and back in again for this to take effect

Winding up

You’re now done and should be able to do all that you need to do in a Linux box on a Windows machine. This should take lots of the pain of Ruby running on Windows away. So that you have a better idea of what you’re doing you should also look to these links for more help: for more on commands for details about the windowing manager installed

you can edit the menu for fluxbox so that Terminator and Scite are included by opening .fluxbox/menu from your home directory and adding in the three lines starting with [exec]. The result just adds them to the end of your menu, so if you want them grouped in another location then follow the instructions at the top of the full menu which is included there under the ‘etc’ directory.
NOTE: For ABDN we don’t need to declare the proxy any longer, but I leave it here in case it helps someone else.

begin] (fluxbox)
[include] (/etc/X11/fluxbox/fluxbox-menu)

[exec] (editor) {scite}
[exec] (console) {terminator}
[exec] (google chrome with proxy) {google-chrome –proxy-server=}

Look at for alternatives to Fluxbox if it’s too minimalist for you.

You will now have a basic system to run what you need for the AWAD course using ruby and rails. You will need to learn more about using Ubuntu, and linux commands, but this will get you started and provide a system where installation of ruby gems and other tools should go smoothly.

The University of Aberdeen is a charity registered in Scotland, No.SC013683