• We are trusted partners of:

Web development using the Virtual Machine (VM): why and how - INNOBYTE - Serious Web Development

Posted by | January 31, 2012 | Development | No Comments

I’ll go straight to the subject: you’ll ask “why use VM? It sounds like trouble!”

There is this myth that the host machine works terribly hard when VM starts and there’s nothing else you can do in the meantime. This is probably true if while web developing you also want to encode MPEG4 a raw video at HD resolution.

VirtualBox

The virtualization technology has gone a long way in the past couple of years, and, thus, a decent host machine (dual core, 2 GB RAM) works well if you have a VM with Ubuntu 10.04 without Gnome/KDE (with no X) and with Apache, PHP, MySQL to which you assign 512 MB RAM and that will also run smooth.

There is also the myth that if you work by yourself for your projects, and not with a team whereby you feel the need of standardizing the development environment, you don’t need a VM. If your projects will always be for the same platform (Apache, PHP, APC, MySQl versions) and if they will be small, than you might be right. But, you may encounter the following situations:

  • For the project X you will need a NGINX + PHP5.3 + FPM + MongoDB setup because it’s a great project developed on cutting edge technologies that incites you to the point of working on it day and night
  • For the project Y you will have a APACHE + PHP5.2 + MySQL5.1 setup because it is a project you started two years ago and you have a great maintenance contract
  • For the project Z you will have a APACHE + PHP5.3 + MySQL5.5 setup because it is a project you could not say no to; you’re doing it for a friend even though it brings no money and it’s quite boring, but it needs to be developed on a platform that requires the setup to be mentioned.
  • You know that on a daily basis you need progress with each project  at least for 2 hours of work

The solution for this situation is to have a VM for each project. Joggling with work for the projects is just a matter of start/stop of the VMs.

However, as it probably happens to most of us, we work in one or more teams for several projects, each with its limitations in matters of hosting service.

It frequently happens that new people join one team or another, on one or more projects. Basically, using a VM, the time spent in enrolling into one project or the other decreases from several hours, or even one or two days for complex setups, to minutes.

I had three failed attempts before managing to pull off the first successful project developed in VM. Today I use VirtualBox (excellent and free) and set up the VM with two network interfaces, this way:

  • Adapter 1: Hostonly Adapter, Intel PRO/1000 T Server
  • Adapter 2: NAT, Intel PRO/1000 T Server

I have manually set the first interface:

root@dev:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.56.10
netmask 255.255.255.0

For easy acces to every system file on Windows  I forced under Samba user and group root:

root@dev:~# cat /etc/samba/smb.conf
#
# …………….
#
[totsystemul] comment = Global Share
path = /
read only = No
guest ok = Yes
public = Yes
browseable = Yes
create mask = 0666
directory mask = 0777
force group = root
force user = root
[www] comment = var/www
path = /var/www
read only = No
guest ok = Yes
public = Yes
browseable = Yes
create mask = 0666
directory mask = 0777
force group = root
force user = root

In a future article I’ll discuss about some other aspects of working with VM and I’ll show you a VM already set up with the help of which you can start working for your new project!

«Go back

Leave a Reply

Your email address will not be published.