Setting up a PHP Development Environment in Windows

Setting up a PHP Development Environment in Windows

Getting started developing can be very difficult, one of the most difficult things to do is to setup a quality development environment. This article aims to ease those frustrations by showing you what tools you will need and how to configure them to maximize your development time.

Step 1: Download an *AMP binary

Download WAMP. This binaries package for Windows contain Apache (web server), MySQL (database), PHP and Perl. WAMP also comes with PostgreSQL (another database). Get it? Windows Apache MySQL PHP (WAMP). You also have the option of using XAMPP; XAMPP get its name from its ability to work on Mac or Windows. Regardless, I typically use WAMP for local development because it is really easy to setup modules and it allows you to easily use multiple versions of Apache and PHP. XAMPP is a bit closer to production level and contains security enhancements not present in WAMP, but if you aren’t going to be exposing your server to the external world, this shouldn’t be a problem. For the purposes of this article, we will be using WAMP.

Step 2: Install *AMP

Install your chosen binary, if prompted to setup a root password for mysql, do so. MAKE SURE YOU NOTE THIS PASSWORD, it is not impossible to fix a lost root password, but you should really be careful with your root passwords. If it asks you where you want to install it, set it up as close to the root drive as possible and try not to put any spaces in the path (as it makes scripting a bit of a pain).

C:\wamp or C:\servers\wamp

Step 3: Configure Apache

There are already quite a few Apache modules enabled by default in WAMP. We want to make sure the following are enabled (you can enable modules by clicking on the gauge icon in your toolbar Apache > Apache Modules > (click on name to enable/disable it)

  • mod_rewrite (or rewrite_module)
  • php5_module
  • mod_deflate
  • mod_gzip
  • expires_module
  • mod_cgi
  • dir_module
  • including_module
  • env_module

Go to your installation folder (ex. C:\wamp) and navigate to bin > apache > Apache X.X > conf > httpd-vhosts

Add a line like this to the bottom:

<VirtualHost *:80>
ServerName local.mysite.com
DocumentRoot "c:/Servers/wamp/www/mysite.com/httpdocs"
SetEnv APPLICATION_ENV "development"
<Directory "c:/Servers/wamp/www/mysite.com/httpdocs">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Save your file and restart apache (this can be done through the *AMP interface

Setup your hosts file

Open up Notepad (right-click and select Run as Administrator if you are using Vista or 7). Once Notepad is open, select File > Open and paste this in:

%windir%\system32\drivers\etc\hosts

ADD the following line:

127.0.0.1 local.mysite.com

Make sure you replace mysite with your website’s name.

Test it out

Open your browser and navigate to http://local.mysite.com and you should see your website (unless you haven’t put an index.php or index.html file there yet).

Questions?

TwitterTechnorati FavoritesYahoo MailSlashdotRedditGoogle GmailHotmailYahoo BuzzStumbleUponShare

About the Author

Rob McVey

I am a software developer/IT professional helping businesses save money through informed purchase consulting; website development and marketing; and process automation.

Leave a Reply

*