Configuring Apache Webserver

This tutorial is for those people who want to start using PHP + MySQL on windows instead of Linux. This tutorial is written entirely from scratch and is based on my personal experience using WAMP. No guarantee is given on the working of WAMP if you make any changes.
The Apache Webserver’s configuration file is named as httpd.conf and is located in the directory C:\wamp\Apache2\conf if WAMP is installed in C:\Wamp directory.
The rules are simple; any line beginning with # is a comment and is simply ignored by Apache while reading its configuration. Line numbers are given for quick reference. They are the default values and can be different is you have changed your settings. Just look out up or down with reference to the line number for what you are searching for. The Apache version used in this tutorial is 2.2.4. For each change to take effect, you have to restart the server

Changing Server Root:
The directory of Apache where Apache is installed and all configuration files is kept. This includes all error and log files. This can be changed by changing them in line 42.
It reads as ServerRoot “c:/wamp/apache2”
You can change this to “c:/Program Fileswamp/apache2” if you had installed WAMP in program files directory. Note the front slashes as opposed to backslashes which is normally used on windows. All paths on Apache contain slashes no matter what is the Operating System.

Making Apache listen to specific IP address or none:
For this just uncomment out the line which reads out like #Listen on line 52. If you want Apache to listen to some IP say, change with the required IP address. Setting this to blocks all incoming requests.

Making Apache listen on port other than 80:
By default Apache is made to listen on port 80, but sometimes other webservices are also running on the same port which may give rise to ambiguous situations, you can make Apache to listen to any other port other than 80, the best alternative is port 8080, which is the alternate HTTP port, if some other service is running on it then better try out 8180. To change it just change Listen 80 on line 53 with other port no eg Listen 8080 or Listen 8180

Loading Modules:
Its pretty easy to do so, just uncomment out the # before the LoadModule word. Its starts on line no 67 by default.
The general look for a loaded module looks like
LoadModule modulename_module modules/
And that of an unloaded module
#LoadModule modulename_module modules/

Changing the root directory of Apache where you keep your scripts:
You are provided with a folder where you have to keep your scripts and execute it via the Webserver. In Linux it is /var/www and /var/www/html in older versions of Apache. In windows it is C:\wamp\www\. This is given in line 150. It is written as
DocumentRoot “C:/wamp/www”
Change C:/wamp/www with any other location like C:/windows/myfolder or any other. Take care of slashes, they are not backslashes.

Configuring you server to be accessed remotely:
Go to line 178, under this are the features for the root directory which Apache accesses. In line 206 change Deny from all to Deny from none and Allow from to Allow from all. You may even try appending a line Satisfy all after the Allow line.

Making your custom error pages:
It’s not much of a headache, just create the page in any file type e.g. html, php etc. Now in line 425 just see the format of adding files. An error code 404 is most famous. It means that the file you requested in not present. Append an extra line to the code and write
ErrorDocument 404 /error404.php

This file should be present in the root directory where Apache is installed. Similarly you can try out other errors by just replacing 404 with any that error’s code.

3 thoughts on “Configuring Apache Webserver

  1. “Throughout this grand design of things you’ll receive an A just for hard work. Where you actually confused us was first on all the facts. As as the maxim goes, the devil is in the details… And it could not be much more accurate here. Having said that, allow me tell you what exactly did deliver the results. The authoring can be highly engaging and that is probably why I am taking an effort in order to comment. I do not really make it a regular habit of doing that. Second, although I can notice a leaps in reasoning you come up with, I am not really convinced of how you appear to connect the points which inturn make your final result. For right now I will, no doubt subscribe to your position however hope in the future you actually link your dots better.”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s