Virtual Server Setup

Saturday, June 28th, 2008 at 9:35 am

Recently, I needed a clean environment to do some development for a project at work. The OS (ubuntu) I have installed on my development computer wasn’t the same as what the application was originally developed and deployed in (red hat) and this was causing a few issues. I debated bringing up a slicehost slice solely for coding and testing, but this seemed like a hassle, as well as an extra expense.

Enter virtualization. There are a number of options to create a virtual computer on your host system. The most popular hypervisors are VMware and Xen. What these programs will let you do is create a completely separate installation of an operating system inside your current one. This let me create the clean environment I needed for this project.

VM’s can come in handy in quite a few different situations. There’s the previously mentioned fresh development environment. Also, you can install windows so that you can test sites in Internet Explorer 6 and 7 to make sure things render properly for your clients if you’re doing web development. Also, if you want to test out the latest and greatest release of your favourite distribution, but don’t want to commit to a beta release or something, you can test to your heart’s content in a VM. If you are hosting sites, a VM is a much more cost-effective way to give a client a dedicated environment as opposed to having dedicated hardware.

In my case, I’m running Ubuntu, but needed a CentOS based server to test this code on. To do this in VMware, it was as simple as clicking file -> new virtual machine and a wizard will walk you through the rest of the steps. Also available are pre-built ‘appliances’ which are ready-to-go environments that you need to boot up. (check out the vmware appliance listings).

Initially getting VMware to run was a little bit more involved however. First hit their site and download the latest version from http://www.vmware.com/download/server/ (1.06 at time of writing). While it’s downloading, register for a serial number (yes, it’s free) so that you have that part ready to go when needed. After the file has downloaded, extract it, and run the installer as root with the command

sudo ./vmware-install.pl

This script will run through the entire setup with you. I was able to accept the defaults in most cases, but instead of using eth0 for networking, I switched to wlan0 since I’m on wireless. During the process you may need to compile support for your kernel (don’t worry, it takes care of everything for you. Just make sure you have the kernel headers installed through apt or yum).

After the script finished running and I entered my serial, I was in business, or so I thought. For some reason, running vmware brought up nothing but the following output

~$ vmware
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6)

A bit of googling brought up the solution:

sudo mkdir /usr/lib/vmware/lib/bak
sudo mv /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1 /usr/lib/vmware/lib/bak/.

to move the offending library. After that everything worked great!

After creating the VM, I bumped up the allocated ram from the default 256 up to 512. To get networking working, I switched from Bridged networking to Custom. (do an ifconfig on your host OS to figure out which specific virtual network to use. In my case it was /dev/vmnet8).

The thought of doing this coding project entirely in vi wasn’t too exciting, so I needed a way to access the code that is on the VM from my host OS so I could use Eclipse to do the editing. The easiest way to do this that I found was to mount a folder over ssh using ssh-fuse. (sudo apt-get install sshfs). Then, create a mount point and mount (swap in your VM’s IP / username where necessary).

sudo mkdir /media/vm_mount
sudo sshfs user@192.168.46.128:/var/www /media/vm_mount

next I symbolically linked it to my Eclipse workspace with

ln -s /media/vm_mount ~/workspace/vm_code

And there you have it. Now I can edit the code as if it was local, yet it is residing on a completely separate operating system. Sheer development bliss.

Tags: , , , ,

Leave a Reply