As MacUpdate has just launched an excellent bundle deal that includes the virtualization software Parallels Desktop for Mac, I decided the time was ripe to replace my ageing copy of VMWare Fusion with its creaky installation of Ubuntu Server. Almost all of my web development work is done on my Macbook Pro, and my previous setup of running Ubuntu in a VM as my local web server has worked very well. As my external hosting is done on a VPS running CentOS, I thought it'd be a good idea to start running the popular OS locally as well. Parallels meanwhile has been garnering good reviews, and I was particularly drawn to the improved 3D performance over VMWare Fusion (who doesn't love a bit of gaming now and then), as well as the improved power management features, which should lead to longer battery life.

I had my VMWare Fusion/Ubuntu server setup configured to my particular tastes, and if the new setup was going to work out, Parallels would have to be able to replicate all of that functionality. In particular it would have to:

Let me configure the guest OS (CentOS Linux) with a fixed IP address accessible from the host computer (Mac OS), and Let me keep my development files outside of the VM, i.e. on the host computer, so that I can edit the files in Mac OS, yet have them served by the VM.

Happy to report that everything went swimmingly, and I'm back up and running with my development work within a day. There was a fair bit of trial and error along the way, and I've recorded the steps here for your enjoyment. Hope it helps!

Prepare Parallels networking

The first thing we need to do is tweak Parallel's networking settings. What we need to do is leave a gap in the DHCP range that we can use to assign a static IP address to our VM.

Open the Parallels preferences, and switch to the Advanced tab. Click Change settings next to Network. Under Shared, ensure IPv4 DHCP is enabled Configure the following values:

Start Address: 10.211.55.20

End Address: 10.211.55.254

Subnet mask: 255.255.255.0

Install CentOS

Next we download and install CentOS. I've chosen to download the CentOS 6 minimal distribution as I wanted to keep things compact, and install only the components I need. I've chosen to forego a GUI for example. The installation itself is pretty straightforward, but pay particular attention to the network configuration bit.

Download a CentOS 6 64-bit minimal distribution. The filename should be something like CentOS-6.4-x86_64-minimal.iso, but that will depend on the exact version you're downloading. Open Parallels and select the downloaded ISO. The installation will run. Select Install or upgrade an existing system. Live dangerously and skip the media test. The CentOS installer will now launch. Click Next, the select your language keyboard preferences. Choose Basic Storage Devices. Choose Discard any data when configure the filesystem. Specify the domain name. I've named mine "firefly". You can use anything you like, but remember it as we'll be using this again later. Click Configure Network: Select System eth0 and click Edit. Tick Connect automatically and Available to all users. Under IPV4 settings select Manual from the Method drop down. Under Addresses, click Add and enter the following details:

Address: 10.211.55.2

Netmask: 255.255.255.0

Gateway: 10.211.55.20 (the first IP in the DHCP range)

Under DNS servers, enter 10.211.55.20 again.

Click Apply then close the Network dialogue.

Click Next the select your timezone.

Specify your root password. Click Next.

Choose Use all space, then Next.

Choose Write changes to disk, then wait for the file system to be configured.

The installation will now start. When finished, choose Reboot.

Check and prepare CentOS installation

Login as root with the password you chose during the installation. Check the network settings are correct by entering:

ifconfig You should see a listing for eth0 with a confirmation of the IP address you specified during the installation (10.211.55.2). You should also get a response when you try to ping an outside address: ping www.google.com Upgrade all the installed packages:

yum -y update Install the CentOS setuptool and packages for managing firewall, network, authentication and system service settings:

yum -y install setuptool system-config-securitylevel-tui authconfig system-config-network-tui ntsysv Run setuptool:

setup Now choose Firewall configuration and then Run tool. The firewall should be enabled. Choose Customize then tick the boxes for SSH and WWW to allow access from the host machine. Click Forward, Close, OK, then Yes. I experienced some problems configuring the Apache document root, as well as mounting shared folders in the virtual machine, and found that disabling selinux (Security Enforced linux) solved all of that. To disable it, open /etc/selinux/config for editing and change the Set SELINUX line to:

Set SELINUX=disabled You'll now need to reboot the VM: reboot It's bad practice to be logged in as root all of time, so let's create a normal user account (replace my name with your own):

adduser rob Set a password for the new account: passwd rob Just remain logged in as root for the duration of this tutorial. In the future when you're logged in as the new user, you can perform administrative tasks that require root access by prefixing commands with sudo. We need to tell the system that the new user is allowed to use sudo: Edit the sudo configuration file: vi /etc/sudoers Add the following line to the bottom of the file (again substitute my name for the one you specified when you added the: rob ALL=(ALL) ALL

Install Parallels Tools

The installation of Parallels Tools is required for certain important features to work, notably sharing folders between the guest and host.

With the virtual machine selected, choose Virtual Machine from the Parallels menu, and click Install Parallels Tools… This is supposed to mount the the Parallels Tools ISO, but as that didn't work for me, I had to manually mount it:

mount -o exec /dev/cdrom /media Once mounted you can run the Parallels Tools installer:

/media/install Follow the onscreen prompts to complete the installation, ensuring that you answer yes to the prompt to download missing components. Reboot the VM when finished:

reboot

Install and configure Apache

Install Apache:

yum -y install httpd Configure Apache to start up at boot time:

chkconfig --level 23 httpd on Start Apache:

service httpd start If you now enter the IP address of your guest (10.211.55.2, as we configured earlier) in a browser on the host computer, you should see the default Apache page. Let's make the Apache server respond to a friendly name instead of an IP address. We'll use the domain name you specified during the CentOS installation. Set the domain name you specified as the server's host name (I used "firefly"): hostname firefly Now edit Apache's configuration file: vi /etc/httpd/conf/httpd.conf Do a search for the line containing ServerName, and change it to: ServerName firefly:80 Now add the host name to the server's hosts file. Edit the hosts file: vi /etc/hosts Add the following line to the bottom: 10.211.55.2 firefly Finally, to access the server by this friendly name from the host computer, we need to update the host computer's hosts file as well: 10.211.55.2 firefly

Set Apache's document root to a folder on the host computer

I prefer keeping my actual development files outside the virtual machine. If the VM ever gets corrupted, I know my important files will still be safe and sound. This could also aid you in making backups, as your backup program wouldn't have to backup the entire virtual machine every time a file is changed. Nowadays, Parallels has good Time Machine integration, so it'll only back up incrementally (not so for VMWare Fusion at the time of writing), but I just feel much safer not having my files wrapped up in a container.

With the virtual machine selected, choose Virtual Machine from the Parallels menu, and click Configure. Under the Options tab, select Sharing. Click Custom Folders. Add the folder that contains all your web files, with "Read & Write" permissions. You might have to reboot the VM at this point to pick up the new shared folder(s). Parallels mounts shared folders in /media/psf, so you should now be able see your shared folders there. By default, Apache's document root (the directory from which it serves files), is set to /var/www/html. We'll replace that folder with a symbolic link to the folder we just shared. First we delete the html folder:

cd /var/www rm -rf html/ Next we create the symlink. Replace Sites with the name of your own shared folder: ln -s /media/pst/Sites html

Install PHP

Add the package:

yum -y install php Now restart Apache:

service httpd restart

Install and configure MySQL

Add the packages:

yum -y install mysql mysql-server Start the MySQL daemon:

service mysqld start Configure the MySQL daemon to start up when the server boots:

chkconfig --levels 235 mysqld on Set the root password (substitute <PASSWORD> with your own):

mysqladmin -u root password Optionally follow my guide for creating databases and additional users.

Optionally install and configure phpMyAdmin