Virtualisation used to be a fairly hot tech buzzword but seems to have dropped off these days. Wikipedia describes it as “… the act of creating a virtual (rather than actual) version of something, including virtual computer hardware platforms, storage devices, and computer network resources.”
Running a virtual machine ( VM ) is surprisingly useful for a number of tasks. I use it mainly when I don’t want to install a load of extra software on my desktop machine simply to try something out. Fortunately running VM is quite easy these days and this blog post describes how I go about it. Although I use Linux most of the instructions below will probably work under Windows or Mac OS with few changes.
There are three main steps:
- Installing a virtualisation environment
- Obtaining and configuring a VM
- Running software on the VM
Installing a virtualisation environment
Back in the days when I did software project management for a living we used a lot of VMware products for our virtualisation. This is more of an enterprise level product and is very much “paid for”. There is a “free as in beer” product for personal, non-commercial use called VMware Player which I have also used in the past and is very good. However there is a FOSS alternative, licenced under the GPL V2, called VirtualBox and, having heard good reports about it, decided to give it a go.
The version in the Ubuntu software repository is 5.0.40 but the latest version listed on the VirtualBox site is 5.2.4. As my application wasn’t really very heavy I decided to go down the quick route and installed from the Ubuntu repository. However there seems to be some good features in the later version so I should really update it at some point.
When the application is run then a window as shown on the right is displayed with a list of currently installed virtual machines.
Obtaining and configuring a VM
The OS running in the virtual machine is identical to that running on “real” hardware. So it’s possible to create a VM by just downloading a distribution and “installing” it in VirtualBox. However VMs are usually used to simulate servers which are normally command line based without window managers whereas most distros will include a window manager. Also a general purpose distro is not the best thing to simulate a web server because it needs specific software installed which is not always found in a desktop based OS.
Note that there are a number of formats available for download. Here we need the “Streamable OVA image compatible with VMWare & VirtualBox” version.
To install the downloaded VM then select File > Import Appliance from within VirtualBox and open the newly downloaded file. I use the defaults for the install but there are ( inevitably ) lots of different settings that can be changed – right click on the relevant VM in the list and select “Settings”.
Once it’s imported then I usually change the network adapter to be “Bridged Adapter” because this is the only setting that seems to work correctly for me. Also select the correct adapter – ethernet or Wi-Fi. Finally highlight the VM in the list on the left hand side and click “start”. A new window will open and the selected VM will boot. For the first boot only a number of passwords will need to be set and eventually you’ll end up with the server running and a screen with some useful details as shown on the left.
At this point it’s probably wise to run the usual software update commands to make sure that the OS has all the latest patches and fixes.
Running software on the VM
Copying the software to be tested over to the VM can be done in a number of ways. I use secure FTP ( SFTP ) and I use the FileZilla client. There are numerous clients available but FileZilla is FOSS and I used it for many years under Windows and I didn’t find anything better. It’s reasonably clever when copying because you can ask it to only overwrite if the source file is newer than the destination. This way you avoid copying everything over when updating the software. The alternative is to do something clever with rsync but I’ve never needed to go that far.
The root directory for the web server is at /var/www and I put my demo site in a subdirectory as the root area contains some useful web management tools that I didn’t want to delete. When everything’s copied over then pointing the web browser at the relevant address should bring up the page as shown on the left.
- This post has covered the installation of a Linux based VM. However it’s entirely possible to run a Windows based VM, assuming that a suitable licence is available. In the past I’ve used this approach when I needed to test browser compatibility across a number of different Windows versions ( XP, Vista, 7 etc. ) and it worked very well.
- Using a VM is probably the easiest way to get a clean OS to test installers and software dependencies.