Tuesday, December 30, 2008

Setting up a Test Server on Your Own Computer

When you’re developing a website, you need to see it in action on a real server, to see how it will work. While you could upload your pages to your web host every time you make a change, this quickly gets time-consuming and tiresome. Wouldn’t it be great if you could have a little test server of your own? Well, the server is nothing but a piece of software – so you can! Please note that, for the purposes of this article, I will assume you’re using Windows as your operating system.

Installing an IIS Test Server.

While using IIS isn’t recommended, a test server is very easy to install. All you need to do is open ‘Add or Remove Programs’ in Windows’ control panel. All you need to do is click Internet Information Services (IIS), click OK, and you’re done.

Of course, there are downsides to this. Many versions of Windows don’t come with IIS, and there’s no way to install it on them – Windows XP Professional, for example, comes with IIS, but Windows XP Home does not. You might also want to consider that installing IIS on your computer will often make it less secure.

Installing an Apache Test Server.

Compared to installing IIS, installing Apache is hard – Linux distributions all have relatively easy ways of doing it, but Windows wasn’t designed for it. To get Apache installed, then, you’re going to need to have a little fight with the system.

Note: If you want to skip all the following steps, you might consider using an ‘easy installer’ version of Apache, such as XAMPP (for Windows), which you can get at www.apachefriends.org/en/xampp-windows.html. The downside to this approach is that you will be relying on them to provide new releases, instead of being able to update things yourself.

First of all, download Apache from http://httpd.apache.org/download.cgi. Make sure you download the Windows Installer (MSI) version. You’ll find it easiest to make the server run as a service, as this will make it run automatically – Apache will appear in your system tray (in the bottom-right corner of your screen).

Now, you need to find your Apache configuration file. In the folder where you installed Apache, look for another folder named ‘conf’, and then a file named ‘httpd.conf’. Open this file and look for a setting called DocumentRoot. You should change this to point to a folder on your hard drive, such as ‘c:/html’.

Now, you’ve got Apache, but that’s not usually much good on its own. The chances are that you’ll want to install PHP and MySQL as well, so here’s how:

Download PHP from http://www.php.net/downloads.php. Again, go for the installer. Once you’ve installed PHP, find its folder, and rename the php.ini-dist file there to php.ini. Find the ‘doc_root’ setting there, and set it to the same thing you set Apache’s to.

Back in Apache’s httpd.conf, you should add these lines:

LoadModule php5_module “c:/php/php5apache2.dll”
AddType application/x-httpd-php .php
PHPIniDir “c:/php”

No comments:

Post a Comment