Setting Up a Local Test Server

A practical tutorial on how to set up a local test server.

Having Your Own Web Server Locally

When designing a web application, as opposed to a web site, you will need to make the jump from client-side technologies like DHTML, to server-side technologies like PHP and Perl. In order to successfully develop in any language, you must possess the ability to test your work before you launch it into the public domain of the Internet. This can be problematic, however, if your web site is hosted remotely by a hosting company, where you need to upload your work to their web server before you can test it. This can be a time-consuming process.

In this tutorial, I will show you how to easily set up your own web server on your local PC, using freely downloadable software. The combination we will be working with is:

  • Windows 2000 (any other OS should work fine).
  • Apache 2, as our actual web server.
  • PHP, as our server-side scripting language of choice (Perl, Python or JSP are also excellent).
  • MySQL, as our database server.

In order to understand the relationship of these various technologies and how they fit together, examine the following diagram:

Central to the configuration is the web sever, in this case Apache (we could also use IIS on Windows systems). The MySQL database is also hosted on the server, so all transactions to and from the database will be carried out by the server machine. PHP is going to be our server scripting language, and this will also be executed on the server. The client-side technologies such as HTML and JavaScript are executed by a web browser, such as Internet Explorer, so a server is not required to design and test these technologies, only a web browser application.

This is the traditional model of a client/web server relationship, in our instance the server and the client are in fact the same computer, so all processing is carried out locally. As you can see, the majority of work on a true web application is carried out at the server level; the browser client is really only an interface between the user and the server for input and output.

An Introduction to Apache

The Apache HTTP server has been the most popular web server on the Internet since 1996. To quote "The July 2003 Netcraft Web Server Survey found that 63% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined". As Apache is the central component of our test server, it is important to install it first, as PHP and MySQL will configure themselves for this server when they are installed on your system.

Installing Apache Under Windows

You can download the Apache installer from Once you have it downloaded, double-click the file to begin the installation, and follow these simple steps:

  1. Read the user agreement and accept it.
  2. Choose the standard configuration.
  3. Enter localhost for the network domain and server name, and any valid e-mail address, as in the screen below:
  4. Ensure that on port 80 as a service is selected.
  5. Install the typical version.

An Introduction to PHP

PHP (PHP Hypertext Preprocessor) is an open source server-side scripting language that is widely used on both Unix and Windows based web servers. The name is a recursive acronym in the same style as GNU, which stands for GNU's Not Unix and which began this unusual trend. As PHP derives its syntax from C/C++ and Perl, previous exposure to any of these languages will make PHP easy for you to learn, although no experience is required as there is lots of help to be found online for this popular language. Of course it is up to you to decide on which scripting language to use, for example you could also use Perl, JSP (which requires Apache Tomcat), Python or ASP (although the later requires an IIS server), but as I wrote this web site in PHP and many others, I am a bit biased due to its power and ease-of-use.

Installing PHP Under Windows

You can download the PHP installer from Once you have it downloaded, double-click the file to begin the installation.

  1. Read the user agreement and accept it.
  2. Choose the standard configuration.
  3. As with Apache, enter localhost for the server name, and any valid e-mail address.
  4. Choose Apache as your server, as in the screen below:

An Introduction to MySQL

The MySQL database server is the world's most popular open source database, for both Unix and Windows based systems. It's architecture makes it extremely fast and easy to customize. The minimalistic approach by the developers of the software has resulted in a database management system unmatched in speed, compactness, stability and ease of deployment. The PHP/MySQL combination has become a very common environment to develop fast, powerful and secure web applications across corporate Intranets, and e-commerce portals.

Installing MySQL Under Windows

You can download the MySQL installer from Once you have it downloaded, double-click the file to begin the installation, and follow on-screen instructions (it's best to choose the typical installation for our purposes).

Testing the Server

Assuming that everything installed correctly, you should now have a fully-functional server. Please note that you may have to restart your PC before the server will work correctly. To test your server, open up your favourite web browser and type http://localhost/ in the address bar, and you should see something similar to the following screen in your browser:

This is the default Apache page. However, as we are going to develop in PHP, we will need to replace this page with a file called index.php. Firstly stop the Apache server (there should be an icon on your Windows task bar on the bottom-right to facilitate this). In the windows start menu, choose...

Programs->Apache HTTP Server->Configure Apache Server->Edit the Apache httpd.conf Configuration File

...and change the line that says "DirectoryIndex index.html index.var" to "DirectoryIndex index.php index.html index.var". Now the index.php file will be searched for first. Place any valid php file in the htdocs folder of your server (on Windows 2000 this defaults to C:Program FilesApache GroupApache2htdocs), name it index.php, and restart the Apache server. Now when you start your web browser and navigate to http://localhost/, you should see the results of your index.php file after it has been processed by the PHP interpreter.

Concluding Notes

All of the software I have used in this tutorial are constantly being updated and improved, so the exact nature of the install procedure may also change with it. The installation will also be different dependant upon the operating system that you are using, for example Windows 98 will be different to Windows XP, and Linux will be different again.

If you have any difficulties in setting up your server, ensure that you have read all of the instructions with your downloads carefully, and also check the relevant web sites for additional help. I have deliberately strayed away from testing the MySQL installation as this is quite a complex issue, but rest assured that when you need to use it, your installation will support MySQL; it really is a very easy installation. Now that you have a local web server up and running, you are ready to develop truly dynamic database-driven web applications on your local PC. Enjoy!

John Collins

I have been writing about web technology and software development since 2001. I am the developer of the Alpha Framework for PHP, and the personal productivity app. I love open source, technology, and economics.