Web developers know that a development environment is essential when building large web projects. Sometimes you are graced with the opportunity to work with a dedicated development server, but most small time operations don’t have this luxury. In cases like these, setting up a local development environment on your machine is essential. We don’t want our tinkering and tweaks to be visible to the public, do we? White pages of death, MySQL error message, you name it – these are things we keep to ourselves.
In this post, I’ll go over setting up a local dev environment on a Windows machine. You might be familiar with the term LAMP (Linux, Apache, MySQL, PHP), but when using Windows, unless you want to set up a virtual machine (which is always a good option), a WAMP environment will suffice.
Before we start, I always suggest getting your dev environment as close as possible to your live environment. If your live server is a Linux based server, then you should probably steer away from WAMP – but for those die-hard Windows Server developers, a WAMP environment will do just fine.
First, we need to determine if we want to install an all-in-one server environment, or if we’d rather install each piece one at a time.
Personally, I like the all-in-one installers, and I’ve had good luck with them. They don’t offer the level of customization that manually installed server environments offer, but for most cases they get the job done just fine.
If you want to go the one at a time route, here is where you’ll find the proper pieces:
I won’t go over installing each piece in this post, as each site has great documentation for all environments already.
Let’s go over installing an all-in-one server environment. My weapon of choice is WampServer. I’ve found it easy to work with, and relatively pain free. For my purposes on my Windows machines, it’s worked great.
Click on the latest version from WampServer, and a warning will pop up.
If you don’t already have these pieces installed, do so before proceeding.
VC10 SP1 vcredist_x86.exe 32 bits : http://www.microsoft.com/download/en/details.aspx?id=8328
VC10 SP1 vcredist_x64.exe 64 bits : http://www.microsoft.com/download/en/details.aspx?id=13523
To get the WampServer download started, click the “you can download it directly” link in the popup warning. You’ll be taken to an external site, and the download will begin shortly. The file is slightly large (about 30 MB) so the download may take a moment or so.
When the download is complete, go ahead and run it. Make sure to give Windows permission to install it, and agree to the license agreement.
When you get to the point where you are asked to choose a location to install, I would suggest choosing the default: c:\wamp. Finish clicking through the installer, and let it finish. It may take a few moments.
When that is finished, choose your default browser. Windows will make it Internet Explorer by default, so now if your chance to change it. If you simply do not care, just click Open.
Next, you’ll be asked to set your SMTP mail settings. This will be used when you use the
mail() PHP function. Again, if you don’t care, just click Next.
That’s it! You’ve succesfully installed a local development environment on your server, fully featured with the latest version of Apache, MySQL and PHP. You can start programming right away!
Accessing your local web files
At this point, if WampServer is running, all you need to do is open the browser and go type
http://127.0.0.1 into the address bar. If everything went well, you should see either a message stating “It worked!” or a WampServer page like below.
Your web files are stored in the
C:\wamp\www directory. This is where you’ll add sub-directories to test out your scripts and pages locally.
Another great feature of WampServer, is that it come pre-installed with phpMyAdmin, a MySQL web-based GUI. You can access it by clicking the phpMyAdmin link on your
localhost page, or by going to http://localhost/phpmyadmin/.
If you would like to make modifications to PHP, MySQL or Apache at this point, each is located in the
Setting up a local dev environment is extremely easy and pain-free if you choose to use an all-in-one installer like WampServer. While it doesn’t offer you the level of customization that installing each piece one by one would, I’ve found it to work great for my needs in the past.