Setting up Windows as a PHP development server

Install a WAMP (Windows, Apache, MySQL, PHP) environment in 4 easy steps, one of which is optional and one of which isn’t really a step at all! ;)

These days I’ve been working on Linux servers for a long time, so when I had to install all the things necessary for PHP development on Windows, I realized it isn’t necessarily a simple task… but it can be for you, as I’ve compiled everything you need to know/do to get up and running to this post.

Step 1: Download

The first step is to go to the XAMPP homepage and grab the files. I recommend getting the Installer, because it automates some tasks you’d otherwise have to do by hand.

Step 2: Install & Configure

Run the installer, wait for it to finish and you’re done with the installation. Next, we need to modify Apache’s configuration a bit to enable mod_rewrite, which for some weird reason isn’t enabled by default.

Go to xampp_install_dir\apache\conf and open httpd.conf. Find the line which says:

#LoadModule rewrite_module modules/mod_rewrite.so

then remove the # from the start. Save and close.

Step 3: Fine tune

The things done in this chapter are optional, but can be very convenient.

Go to xampp\apache\bin and open php.ini

Turn on all errors

Since this will be a development server, let’s change error reporting to E_ALL. This way we will get more information on things which go wrong in our code without having to change the error reporting manually. Look for..

error_reporting = E_ALL & ~E_NOTICE

and change it to

error_reporting = E_ALL

Disable magic quotes

Magic quotes are one of the “features” of PHP that usually cause nothing but problems. What are they? Basically, it means PHP will automagically escape quotes in get, post and cookie parameters, often causing issues with backslashes appearing all out of nowhere etc. – Originally intended as a security feature, but it is not much of help, and it’s also being removed with PHP 6, so let’s disable it on our development server as well:

The extension comes with a readme file which explains the installation procedure.

Create a common library directory

The next thing is to create a common library dir. This is something that’s useful if we use the same library (say, Zend Framework) in more than one project, as we won’t have to always copy the library’s code around.

Let’s create a directory for our library files under xampp\php. Create a directory called “library”, then look for “include_path” in php.ini