Configuring Your First Local Apache Website

by Simon. Average Reading Time: about a minute.

Apache is controlled by a series of configuration files but the one we will be dealing with here is httpd.conf. This file contains instructions on how Apache should run. Several companies offer GUI-based Apache front-ends, but it’s easier to edit the configuration files by hand.

Remember to make back-up copies of all your Apache configuration files, in case one of the changes you make while experimenting renders the Web server inoperable.

Also, remember that configuration changes you make don’t take effect until you restart Apache.

Configure the httpd.conf File:

The httpd.conf file can be found in the conf directory in your Apache installation. In my case, this is the following location:

C:\Program Files\Apache Software Foundation\Apache2.2\conf

1. To include the correct default or index file, you need to find the following code and make sure that your default file name is included (see screenshot).

DirectoryIndex index.htm index.html

Apache httpd.conf DirectoryIndex Configuration

For ColdFusion and PHP you would also need to include their equivalents, i.e. index.cfm and index.php.

2. Set up a virtual host definition:

DocumentRoot c:\WebRoot
ServerName localhost

Order allow,deny
Allow from all

Make sure that the directory permissions are set otherwise a directory forbidden message (such as below) will be displayed.

Unsuccessful Apache Configuration

3. Restart the Apache service. You should then be able to browse to your local website.

Successful Apache Configuration

4. If you’re doing something cunning like setting up an alias for the local site, e.g. http://whatley.local/ rather than the usual http://localhost/whatley/ then you may need to edit your hosts file e.g.:

Hosts File Configuration

In my case, the hosts file is found in the following location: C:\Windows\System32\drivers\etc. You can simply edit this file in notepad, much like with httpd.conf.

And that is all there is to it.

This article has been tagged

, , , , , ,

Other articles I recommend

Configuring ColdFusion 8 with Apache

After installing ColdFusion 8 and Apache successfully you may still see an “HTTP 500 Internal Server Error” when navigating to a ColdFusion page. All is not lost, you simply need to configure, or check the configuration of Apache. Apache requires very little post installation modification, but it is always good practice to check the httpd.conf file to ensure that the ColdFusion “install” scripts did what they were supposed to do.

Configuring PHP with Apache on Windows Vista

Installing PHP with Apache on Windows Vista is a relatively simple task until you try an configure the settings in php.ini. Problems can occur and stem from the fact that when you install PHP and edit the php.ini file, you need to not only be logged in as Administrator, but run the installer and Notepad text editor as Administrator. The php.ini file also needs to be located in the Windows directory.

Setting up PHP on Mac OSX 10.6 (Snow Leopard)

Since Apple launched Mac OS X 10.5 (Leopard), PHP has been installed by default, albeit disabled. Here is a quick run through of what you need to do to get it up and running.

  • sir i did all above but when i execute php file

    this itself is displaying no parsing by php is done please hellp me