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)
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
vim /etc/apache2/sites-available/default (change AllowOverride to “All” on every line)
7 – get some nice Drupal settings for VIM
8 – if there is no repository to clone, get Drupal
- or -
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.