Filed Under (Articles) by Anoop on May-11-2007

Step 1 - Download the latest version of Apache.

Goto http://httpd.apache.org/download.cgi and look for the latest stable release. This is currently 2.2.2 and is the version we will use here. Click the link "apache_2.2.2-win32-x86-no_ssl.msi" and Save to an appropriate part of your hard drive. The hard part is done ;)

Step 2 - Install Apache

Double-click the downloaded MSI to launch the installer. You will be presented with the welcome screen.

apache_222_1.jpg

apache_222_2.JPG

apache_222_3.JPG

apache_222_4.JPG

apache_222_5.JPG

apache_222_6.JPG

apache_222_7.JPG

apache_222_8.JPG

apache_222_10.JPG

Step 3 - Lets Configure our new Server.

These instructions configure the Server for SSI as well as taking the ‘VirtualHosts’ approach. This enables you to then add more web sites as needed just by configuring a new ‘VirtualHost’ for each. PHP config options will be added in the PHP tutorial section . Below instructions assume ‘yoursite.com’ as the site name, change to suit yours!!

Locate and edit ‘httpd.conf’ file (should be in ‘C:\Apache2\Apache2\conf\httpd.conf’)

ServerRoot, ServerName, DocumentRoot etc will all have been pre-set according to what information you provided in the intial installation phase. Check these and it is ok to change them manually if your setup needs or locations change.

Locate this code near the bottom of the file :-

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>

and just below it add a new directory container for your base websites files locations.

<Directory "d:/accounts/*/">
AllowOverride None
AddType text/html .shtml
AddHandler server-parsed .shtml
Options FollowSymLinks +Includes
Order allow,deny
Allow from all
AddOutputFilter INCLUDES;DEFLATE shtml
</Directory>

In the above example, this is needed to configure the directory structure for where our virtual hosts will be placed on the server - and this for security reasons is outside of the directory structure for the web server apache files themselves. Here I have created a directory called ‘accounts’ where all websites will be based beneath.

Find the code section:-

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

and make it look like this :-


<IfModule dir_module>
DirectoryIndex index.html index.shtml index.php
</IfModule>

Find the section :-

# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
</IfModule>

and uncomment out those last two lines to read :-

# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>

————–

There is now a supplementary section near the bottom of httpd.conf which gives you the option to include extra configuration files into your setup. In our case, the virtualHosts that we want to configure, instead of doing so at the bottom of this httpd.conf file, we instead enable the ‘httpd-vhosts.conf’ file and do our configurations in there.

Still in httpd.conf file , find the section which is headed by :-

# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

and then find these two lines of code :-

# Virtual hosts
# Include conf/extra/httpd-vhosts.conf

Uncomment out the second line to enable the external vhosts file :-

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Ok, we are done with httpd.conf file but we are not done configuring. We now need to edit /extra/httpd-vhosts.conf and configure our virtual host containers. Save and Close ‘httpd.conf’ file.

Locate and edit ‘httpd-vhosts.conf’ file (should be in ‘..\conf\extra\httpd-vhosts.conf’)
NameVirtualHost *:80 should already be enabled - that is uncommented, if not enable it.

then create a new VirtualHost container for your first site (yoursite.com).

<VirtualHost *>
ServerName yoursite.com
ServerAdmin webmaster@yoursite.com
DocumentRoot "D:/accounts/yoursite"
ServerAlias www.yoursite.com yoursite.dnsalias.com
ErrorLog logs/yoursite.com-error_log
CustomLog logs/yoursite.com-access)log combined
AddHandler server-parsed .shtml
Options FollowSymLinks +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</VirtualHost>

The first VirtualHost container block - or the only container block - is also the fallback default virtualhost should any other requests not be found. More information on configuring VirtualHost containers is at http://httpd.apache.org/docs/2.2/vhosts/

Ok so that about it, Save the file, then ‘Stop’ and ‘Start’ the Server again.

Check that the default site is now our new VirtualHost by going to http://localhost in your browser. Of course you will already have some files including an index page in d:/accounts/yoursite/ or you’ll get a 404 error.

Step 4 - Extra Configurations.
With the new configuration of version 2.2.x of Apache, you may find that some things have changed, some things disabled etc. This extra config section hopefully will show you the way. This page will be updated as I find things.

Enable the local Manual again!
So Apache have decided to disable the local copy of the manual - it is still there, but using up 9MB of disk space and not being utilised. I have been asked - and I asked myself to begin with - why is it that typing in http://localhost/manual gives me an error page instead of the manual I love to refer to ?

Edit your httpd.conf file and locate :-

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

Lets enable the manual by removing the comment from the second line.

# Local access to the Apache HTTP Server Manual
Include conf/extra/httpd-manual.conf

Ok, good thats it, restart the Apache Server service and go to http://localhost/manual and you should have your manual showing again!

If you get an Access Denied message, have a look in ../conf/extra/httpd-manual.conf and check that the location specified in the Alias Match and Manual lines points to the location of the manual directory.

Disable external access to the Manual
Ok, so above we have enabled access to the manual again, and even though Apache have commented it as being ‘Local access …’ , it will also be able to be accessed if you have enabled your website to be accessed externally across the internet. So accessing http://localhost/manual is possible, but so is http://yoursite.com/manual .

You may not care about this, but if you do here is how to disable external access to your manual.

Edit your ../conf/extra/httpd-manual.conf file and locate in the Directory configuration :-

Allow from all

Change this to read :-

Allow from localhost

Restart your Server. Now http://locahost/manual will still work, but http://yoursite.com/manual will not. You can enhance this to allow the whole of your local network access, certain external IP addresses etc etc.



Raghav on February 17th, 2008 at 8:29 pm #

Hey its good..keep it up..!!

Post a comment
Name: 
Email: 
URL: 
Comments: