Archive for March 2010


Using VirtualBox as a local development server, a tutorial.

March 17th, 2010 — 11:49am

Having a local development server makes testing new web code, sites, etc much faster (and cheaper!) then using hosting somewhere. There are a lot of applications that bundle/install a LAMP-like service onto your computer, but then you don’t learn all the fun and tricky things it takes to administer your own web server, as well as enjoy full control.

This was my thinking, so I set about to use VirtualBox to create a virtual machine, and use that virtual machine as my web development server. It doesn’t take long to figure out on your own, but to save anyone the time, I thought I’d log my findings in the form of a tutorial.

First, you want to make your virtual machine in VirtualBox. I used Ubuntu 9.10 Server Edition as my OS. Once it is installed and configured, we can start making the changes to access what your virtual machines apache is hosting.

When you install VirtualBox to your computer, it has a home directory somewhere. In a linux environment, that resides at:

~/.VirtualBox/

The file we need to configure is an xml file with the same name as the virtual machine you created:

~/.VirtualBox/Machines/<vmname>/<vmname>.xml

In the <ExtraData>, we need to add the port forwarding. By this I mean, when you go to localhost:8080 on your browser, it will connect to what your virtual machine is hosting. The commands are very simple.

<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/web/HostPort" value="8080"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/web/GuestPort" value="80"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/web/Protocol" value="TCP"/>

In English, this is saying, “When the host machine looks at port 8080, send it to the virtual machines port 80, and this is using the TCP protocol.” When you point your browser to localhost:8080, it should now show you what your virtual machine is hosting.

I also wanted to easily access the virtual machine, so I added the ability to ssh to it.

<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="2222"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP"/>

So, when at my console I enter: ssh -l -p 2222 localhost it will ssh to the virtual machine. (A word of caution, be sure to actually install openssh on your virtual machine. Otherwise you will spend dozens of minutes trying to figure out why it isn’t working. At least, I’m sure that could happen to someone.)

And that is it!

Comment » | tutorial

Something to Show

March 2nd, 2010 — 6:14pm

I found a great motivational post in my RSS feeds today. It’s from Kellbot, a fairly random blog I read. She popped up on my radar because she was mentioned on BoingBoing once about making a trackball input device for a PS2, and that’s cool.

Anyway the post is about being Self-Employed or Unemployed, and how to make it.
http://www.kellbot.com/2010/03/staying-awesome-while-youre-unemployed/

You should read it yourself, but one point that really hit me like a meaty punch in the gut was this:

“Either way, you should have something to show for the time you haven’t been rotting away in a cubicle. Make other people jealous of you rather than pity you.”

Holy wow. I always feel like I can be doing more, and some of my projects are taking much longer than I planned. And a lot of that has to do with me, and letting other things get in the way of my goals.

I should get “Make other people jealous of you rather than pity you” on a banner for my office/workspace.

1 comment » | Random

Back to top