Drupal development with OSX, VMWare Fusion and CentOS 5.3

Submitted by Janak on Wed, 07/15/2009 - 16:05

CentOS powers my personal websites and since it is based on RedHat Enterprise Linux (which we use at work) it makes my life easier when jumping back and forth between servers as all the filepaths are same, repositories and packages are all consistent. All in perfect harmony as far as work and personal web server are concerned.

Being a Mac user at home and a PC user at work (fanboys hold your guns), I wanted a local development enviornment for my macbook, environment that was consistent with my work and personal web server. So far I had been using the OSX native Apache server + MySQL + PHP. So, naturally the software versions are not the same, OSX does not use /var/www/html as the default apache directory (list goes on..)

I went about trying to install CentOS 5.3 for VMWare Fusion on my MacBook, it was anything but easy. The net installer failed on me around 4-5 times. After wasting hours here is how I went about it all..

Download CentOS 5.3


You can use any of the ISOs, perhaps try the net install and if that does not work, you could download CD1, for a minimal server install that is all you will need. For those of you who are in a hurry or just too lazy, grab a VMWARE Image of CentOS 5.1 here http://www.vmware.com/appliances/directory/1122

Install CentOS 5.3 in VMWare Fusion

I wont go into details here, if you have used VMware Fusion before, you will know how easy this is.

CentOS 5.3 Installation Setup and Config

Again, this has been covered in great length already and I feel I cannot improve upon this fantastic walkthrough at http://www.howtoforge.com/perfect-server-centos-5.3-x86_64-ispconfig-3 and http://www.howtoforge.com/perfect-server-centos-5.3-x86_64-ispconfig-3-p2, you wont need much beyond the first 2 pages.

Almost all of the procedure is the same, with the exception of initial package installation. Since I wanted a bare minimal installation, here is what I installed initially:

  • Editors
  • DNS Name Server
  • Mail Server
  • Server Configuration Tools 
  • Administration Tools
  • Base
  • System Tools

After the reboot, login and setup additional user plus yum install apache, php and mysql among other packages.

OK, the hard part is done.

VMWare Fusion DHCP - Static IP for CentOS Server

Since VMware Fusion allocates a IPs randomly to guest OS, I needed to change the VMware config to ensure my local CentOS server always had a fixed IP.

VMware uses vmnet8 interface for virtual NAT networking and can be configured in the /Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf file (OSX).

Here is what it looks like on my setup:

subnet netmask {
  option broadcast-address;
  option domain-name-servers;
  option netbios-name-servers;
  option domain-name "localdomain";
  option routers;

For each VM OS you can add additional config lines as below:

host CentOS-5-64-bit-vm {
    hardware ethernet 00:0c:29:4b:b9:a3;

It is important that your machine name does not contain any spaces (it is easy enough to rename the VM OS in VMWare Fusion).

Ethernet Address:
Inside the Guest OS you can find out your virtual ethernet id by typing ifconfig -a or alternatively you can take a peek inside guest machine's VMX file (located in ~/Documents/Virtual Machines/myos/myos.vmx)

You can choose an IP address, but ensure this is outside the subnet range specified in the original dhcpd.conf 


Restart the VMWare daemons

sudo "/Library/Application Support/VMware Fusion/boot.sh" --restart

Setup local domains for your VMGuest

To test and access your development server, you can SSH on from OSX Terminal, but it is easier to setup local domain names for actual web development.

In OSX you can edit your /etc/hosts file as below:  dev1 dev2 dev3

And there you have it, a local development server that is perfectly in sync with your remote setup. Ofcourse, this method can be repeated with any Linux OS of your choice, CentOS is the one I use for mine.

This by no means is a comprehensive guide as I am fairly new to Linux myself, so, please feel free to comment and share your thoughts and ideas.

Further Reading and References
How to set up networks and dhcp on vmware (on Mac and other OSs)
DHCP on VMWare Fusion