Testing Server Side Processing Before you Upload

The best place to create your web pages is on your own PC. This enables you to create and test your pages when you are not connected to the internet and you only need to be connected in order to upload the finished pages. It also means that the pages that you upload are finished pages and not pages under construction.

This works very well for all of the client side code that you place in your page as this is processed by the browser once the page has been downloaded to your computer and as your pages are already downloaded you can test all of the client side coding such as HTML and Javascript on your computer just by using a web browser. I do recommend that you test your pages in different browsers since the page source may be interpreted differently by different browsers.

The problem comes with server side processing that you include in your pages as these statements need to be interpreted by the web server and therefore wont work properly when you access the pages directly on your own computer.

One solution to this is to install a web server on your own computer. The Apache web server is available as a free download for most operating systems and by running this server on your own computer you will be able to test some of the server side processing that you include in your pages without having to first upload your pages to the web.

The first thing that you need to do is to download the version of Apache for your operating system.

Next you need to configure Apache to run as a stand alone system on your computer. This involves editing the httpd.conf file that you will find in the conf folder/directory under where you installed Apache. The lines that you need to edit initially in order to get Apache to run are:

 ServerName localhost
DocumentRoot "g:\myweb"
<Directory "g:\myweb">

These lines identify this server as being a local server and identify the directory on your drive where the http://localhosts/ address will point. If the web server that hosts your pages on the web uses a home page other than index.html then you will also need to edit the line that reads: DirectoryIndex index.html to reflect the default file name that you want.

You will also want to check the hosts file on your computer to check for an entry that reads localhost

You then need to install Apache so that it runs as a service in the background whenever your operating system starts up. How you do this depends on your operating system for example on Windows NT you sign on as Administrator, run apache -i from a command prompt to install the Apache service then go into services, select Apache and click Start. Once you have done this the Apache web server will run every time you run your system and you can access web files within the specified directory from the http://localhost/ web address.

This gets the web server running. Next we need to make whatever changes are necessary to get the appropriate server side activities to work.

To turn on server side include support on your newly installed web server you need to make the following changes to the ttpd.conf file: add Includes to the option statement within the directory section eg.

 Options Indexes FollowSymLinks MultiViews Includes

and also uncomment:

 AddType text/html .shtml
AddHandler server-parsed .shtml

This will allow you to test your SSI codes on your own computer without having to upload it to your web host's server first remembering of course to name all of your web pages containing such includes with a .shtml suffix instead of .html or .htm (because the server will be configured to only parse .shtml pages for server side includes because parsing all pages is too slow).

You can make similar changes to the file to install cgi support and support for server side image maps allowing you to test all of these features on your own computer before uploading your pages to the web.

Note that there is no point installing these features on your own web server if the server that hosts your site doesn't support the same features as this will result in the pages working on your own computer but not on the host.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow