VMware as a (Joomla) web development server.

**This is a setup for my PERSONAL use and works well as such. I would suggest something different in a team environment.

In my afterlife as a try-hard Joomla web developer who only ever dreams of having my sites getting a full validation at www.wc3.org, I have tried a number of different setups to get an effective development environment happening. Here’s a setup I have been using for about a year that works well for me, scales well for multiple websites and is quite simple to create more hosts.

My development machine is actually a VMware Virtual Appliance that lives on my desktop. I use The Free VMware server as opposed to the Workstation edition because I like to have it running as a service.

I have a Samba share that’s mapped from /home/user/public_html in the VM to /home/user/public_html in the host (my desktop). In the public_html folder, I create new folders that act as Virtual Hosts representative of their real domain or the username of the CPanel live server. My Virtual Machine is setup using the “DMZ” server setting from the router, this mostly just saves me configuring the NAT back at the router. Instead, I use the Suse Firewall to control access to ports.

My Virtual Hosts and their Folder Locations are like such:

/home/user/public_html/user1 -> user1.domain.com
/home/user/public_html/user2 -> user2.domain.com
/home/user/public_html/user3 -> user3.domain.com

Virtual Hosts can be setup via Yast but since I previously used Mandrake (Mandriva), I was accustomed to creating Virtual Hosts by hand and I still find this easier.

In Suse, you can find the file for modification here:

/etc/apache2/vhosts.d/yast2_vhosts.conf (in Mandrake is was /etc/http/conf/vhosts.d/Vhosts from memory)

And the entries that give us what we need for name based virtual hosts are:

 DocumentRoot /home/user/public_html/user1
 ServerName user1.domain.com
 ServerAdmin user@domain.com
<Directory “/home/user/public_html/user1”>
  Options FollowSymLinks
  AllowOverride Indexes AuthConfig FileInfo Limit Options
  Order allow,deny
  Allow from all
  DirectoryIndex index.html index.php
 UserDir public_html

To make it available externally then you need to create an A record in your DNS that looks like:

<your_external_ip>    user1.domain.com

(If you do not have a static IP address from your ISP, then you can use a service like www.dyndns.org)

So “externally” ie: from outside the router, I can access all my Apache Virtual Hosts via their DNS (ie:user1.domain.com) and I run .htaccess files that look like:

AuthType Basic
AuthName “Web Dev Server”
AuthUserFile “/home/user/.htpasswds/passwd”
#deny from all
# LAN Addresses
Allow from
# WAN Address
Allow from
require valid-user
satisfy any

This allows unauthenticated access from ip addresses / ranges yet requires others to authenticate as a fallback.

In my Default Apache Server instance, I run a little PHP script to display the Client’s IP address. When I am working with a client, I can ask them to visit the default page, giving me their IP address, which I can then add to the .htaccess file to give them access to view the site under development without needing to authenticate.

For INTERNAL hosts ot if you don’t want to use DNS, it’s necessary to add the entries into /etc/hosts (for Linux) or %SystemRoot%\system32\drivers\etc\hosts (for Windows) in the following format either on the same line or separate lines ie:     user1.domain.com     user2.domain.com
or    user1.domain.com    user2.domain.com

Whatever rocks your boat.

So, effectively what this gives us is:

user1.domain.com (and others) is accessible by the outside world via dns – Certain IP’s are automatically authenticated, else a user / password is required.
user1.domain.com (and others) are available via the Hosts file internally without requiring authentication (obviously this doesn’t scale too well if you have many internal hosts and you should consider other options)

/home/user/public_html/ is mounted locally using Samba and available to create sites in Dreamweaver (I am using Wine on Linux). Samba is used rather than NFS because we sometimes mount this from a Windows Desktop. Using this rather than FTP, Dreamweaver sees it as a local drive.

I always leave a fresh setup of Joomla with the basic modules and components that I use installed. This, I use as my template. The process for creating a new website is something like:

Create Site:
cd /home/user/public_html/
mkdir user3
cp -R joomla/* user3/
vi user3/configuration.php (modify paths and database details)

Create Apache Virtual Host:
sudo vi /etc/apache2/vhosts.d/yast2_vhosts.conf, copy and paste an existing site and modify paths and server name
sudo /etc/init.d/apache2 restart

Using Navicat:
Create new database ‘user3’
Data Transfer host:user1.domain.com db:joomla_template -> host:user3.domain.com db:user3

Done! We have a new site with all my personalised components, templates, modules already setup.

MySql side note:

I access all mysql databases inside the VM using Navicat – the Windows version runs under Wine beautifully (much better than their Linux version actually). Navicat is definitely a tool worth paying for. When I migrated from Windows, I exported my HKLM/Software/PremiumSoft key from the Windows registry into Wine and copied my Navicat folders across, which imported all mysql host definitions saving me from setting them up again. Alternatively, if you are a Free, Open Source zealot then you can use mysqlcc or mysql-administrator to access your databases. The biggest praise I have for Navicat is it’s “Data Transfer” tool to move complete databases from host to host.

Time for some VMware Philosophy.

Why do I run everything in a Virtal Machine? Because, I essentially see it as my “Server” platform with the advantages of not generating more electricity, heat, noise, space etc (there was a time I had 5 physical machines in my loungeroom and it was UGLY). Additionally, the environment is much more static than my desktop. I might want to upgrade my desktop in 3 months or 6, I don’t know but I certainly don’t want to move 35 mysql/php/python websites, a mail server, spamassassin, antivirus, dns etc, etc. Additionally, if I want to plan some downtime on my main host, I can just suspend the Virtual Machine and copy across the whole file to my wife’s computer, unsuspend upon it’s arrival on her machine and the Virtual Machine and the mail server and websites can be running again while I don’t have to be concerned with my mail server being down.

Unresolved Issues Encountered:

The MAIN issue of running this setup is that when I reboot, Samba from the host machine tries to mount the public_html share of the VM before the VM has had a chance to finish booting. Thus, the Samba share fails and I need to manually mount it once the Desktop is loaded.

Technorati Tags: , , , ,

Published by salubrium

I am a Systems Administrator based in Sydney, Australia with some hugely varied interests: Topics covered are Virtualization, Web Hosting, Remote Desktop, Security and Backups, PHP, Python, MVC Frameworks, SEO

Leave a comment

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