Using VM Ware for Web Development

A web developer, especially one who focuses on Drupal, has to have a stable platform on which to work in order to be the most productive.

After many years of struggling to find the right combination of hardware manufacturer, operating system, software, integrated development environment (IDE), and server operating system, VM Ware came to the rescue.

Workstation 8 (Windows) and Fusion 4 (Mac) both offer the same benefit – an autonomous, quarantined development environment, into which one may SSH and be certain that there exists no bleed-over from other projects.

As anyone who has worked with Drupal knows, the environment can be very sensitive and create white-screens-of-death (WSOD) if even one semi-colon is deleted, or one .htaccess entry is mangled.

This is where VM Ware comes in – simply create a default environment (such as Ubuntu 10.04, Mint 12, or another preferred Linux release) and configure everything needed to be up and running as a Drupal developer in no time for each new project.

Begin by following VM Ware’s simple instructions for creating a virtual machine using a disc or an .iso file. When the machine is up and running, configure this as the default “template” machine, off of which dedicated project machines will be cloned.

Here are some suggested configuration niceties after (Debian flavor) Linux is installed on a default VM instance:

1 – break out of Ubuntu’s forced user scheme from a terminal with

sudo su –

passwd (reset root password)

2 – disable the default firewall (unless you are on a public IP)

ufw disable

3 – start creating a development environment

tasksel install lamp-server  (may have to run apt-get install tasksel depending on the version of Linux)

ssh-keygen -t rsa (to create a ssh keypair)

cat ~/ .ssh/id_rsa.cab (will print out the ssh key needed to connect to the Git   repository, if needed)

4 – install tools

apt-get install vim

apt-get install git-core

apt-get install drush

apt-get install openssh-server

5 – set up gui tools

apt-get install phpmyadmin

vim /etc/phpmyadmin/config.inc.php (uncomment AllowNoPassword so as   to log in as “root” with no password)

6 – create Drupal-friendly settings

a2enmod rewrite

vim /etc/apache2/sites-available/default (change AllowOverride to “All” on   every line)

/etc/init.d/apache2 reload

7 – get some nice Drupal settings for VIM

http://drupal.org/node/29325

8 – if there is no repository to clone, get Drupal

cd /var/www

wget http://ftp.drupal.org/files/projects/drupal-7.12.tar.gz

– or –

wget http://ftp.drupal.org/files/projects/drupal-6.25.tar.gz

tar xvzf drupal-X.tar.gz

9 – Run the Drupal install from a browser on the main system (127.0.0.1 / localhost), pointing to the IP address assigned by the VM Ware instance (use ifconfig in the VM Ware machine’s terminal to get the IP)

10 – Shut down the virtual machine

11 – In Windows, simply clone the the virtual machine just created into a name representative of the project. In Mac, go to Finder and copy and rename the file. Reboot the virtual machine so it assigns it a new IP address, differing from the template machine.

12 – Connect to the new development environment and clone a repository into /var/www if the project already exists.

There is now a separate “server” running an entire site in development, with no possibility of damage from other projects. This is very useful, especially if there are multiple collaborators (you never know who is messing with /var/www/sites/default/settings.php)!

Some final thoughts:

The “hosts” file can be edited to enable connection to a VM machine via URL (e.g. 192.168.213.132   www.mysweetnewdrupalsite.com).

Establish multiple SSH sessions using PuTTY or iTerm2 from the main machine into the VM machines, and scp files from here to there, or even ssh from one VM machine to another.

Use Chrome and/or Firefox on the main machine to develop on the VM machine.

Happy coding!

Adam Behnke

Adam Behnke

Adam is a mobile/web developer for Accella who has been developing telecom and web applications since the mid-90's, before the dot-com bust. With a heavy telecom background, Adam can speak fluently in 3GPP, ASN.1, SS7, and SIGTRAN as well.

One Response

  1. You can go further by using mod_vhost_alias and VirtualDocumentRoot to map subdirectories to subdomains.

    That way starting a new project is as easy as creating a new folder, and browsing to http://new-folder-name.virtualhostname.

    I’ve actually gone as far as buying a domain name for this purpose (http://virtualbox.me) and pointing all subdomains to the IP address of my local virtual machine. So if you setup the same local IP as I use, you too can use the virtualbox.me subdomain for the same purpose.

    Full guide here:

    http://otaqui.com/blog/1652/setting-up-a-virtualbox-virtual-machine-for-web-development-with-multiple-sites-using-mod_vhost_alias-and-virtualdocumentroot/

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

Search

Recent Posts

Most Common Tags