So, what do you do when you need to write code that uses PHP, Apache, and MySQL all on the same computer? The simple answer is to install them using a WAMP or MAMP package. However, this approach has a few drawbacks:
- You end up with a jumble of server applications running on your computer all the time.
- Your configuration of the various packages will be different from the actual server environment you’ll be using, so some of the setup details will be different. The ported versions of PHP, Apache, and MySQL aren’t exactly the same, and the idiosyncrasies of your home operating system and hardware configuration can lead to weird bugs.
Plus, it’s just plain messy! The ideal case, from the testing perspective, is to actually have a separate development server running the way that your deployment server is set. And that server is likely to be a LAMP (Linux / Apache / MySQL / PHP) setup running an enterprise version of Linux. My websites, for example, run on a Media Temple dedicated virtual server using CentOS, which is the “community” version of commercial Red Hat Linux. So, if I’m developing a dynamic web site using PHP/MySQL, it would be best if I could actually set up a separate server on my home network that is configured in the same way. This works great…unless you don’t have internet access, which is something I face pretty frequently when I’m working away from the house.
The solution to this conundrum is to actually run a virtual server on my development laptop. I’m using Virtual PC, which is free from Microsoft, to create a 256MB CentOS machine. The tricky part is configuring it to connect to the laptop’s networking subsystem and CentOS to recognize it, but I now have a good portable setup. When I want to do development, I can start up the Virtual CentOS machine, and point my web browser to it. I can also SSH into the CentOS machine just like any other, which makes the development process very similar to working with my Media Temple (dv) server. The closer I can make each environment to each other, the more fluid my development workflow will be.
A big advantage of using virtual machines is that all the messy configuration details are contained in them, and the rest of my laptop remains pristine. I can also take snapshots of each virtual machine and restore them to saved states, which makes it easier to try different server configurations.
The details of the setup I need to reconfirm, but I have a Wikilab Entry that maintains my working notes.
0 Comments