Friday, September 3, 2010 3:26

How to Install and Configure Apache

Posted by Michael Ashworth on Saturday, August 15, 2009, 6:34
This item was posted in Tutorial and has 3 Comments

Having recently moved to a new laptop and  just gone through this tricky process once again, I decided to write up these notes mostly for myself, and to put them online so I will be able to find them if ever I need them again (which I probably will)… so they are tailored to how I like to set up Apache!

For example, I like to partition my hard drive to separate the Windows System from Programs and my Files, so instead of using the default location (usually under C:\Program Files\) I will be installing Apache on drive D: and keeping the local copy of my website(s) on drive E: …

apache-installation-wizardINSTALLATION

1. Download Apache 2 [ http://httpd.apache.org/ ] & Run the Installer

2. At the “Server Information” page:

* enter “localhost” for Network Domain and Server Name
* and anything for Administrator’s Email Address
* leave the default setting “for All Users, on Port 80, as a Service” as it is

3. At Setup Type, select “Typical”

4. At Destination Folder

* select where you want the Apache program to be installed, e.g. D:\Apache2.2\

CONFIGURATION

1. In Control Panel -> Administrative Tools -> Services -> “Apache2″

* stop the service (nb. you cannot edit the configuration file while Apache is running, so the service MUST be stopped before the next step)
* and change the startup type to “Manual”

2. Use a basic text editor (e.g. notepad) to open the file “httpd.conf” in the folder “%Apache2%\conf\” (where %Apache2% is the path you set in step 4 above i.e. D:\Apache2.2\conf\httpd.conf)

3. Search for the text “server-side includes” and delete the hashes at the beginning of these following lines:

#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml

Thus, they should read like this:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

4. Search for “DocumentRoot” and edit the following line:

DocumentRoot "%Apache2%/htdocs"

to point to the path where you want to save your website(s), e.g:

DocumentRoot "E:/home"

5. and just below that you will find the line:

<Directory />

Do not edit it, but look below that you will find the same line again. Edit:

<Directory />

to read:

<Directory "E:/home">

6. a few lines further down you should find:

Options Indexes FollowSymLinks

Edit it so it reads like below:

Options Indexes FollowSymLinks Includes ExecCGI

7. Search for the following line:

#AddHandler cgi-script .cgi

and delete the hash so it reads:

AddHandler cgi-script .cgi

8. a few lines below that you will find:

#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml

delete the hashes so these lines read:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

9. Scroll to the end of the file and add these lines, one group tailored for each of your local websites (note each must have a unique URL 127.0.0.xxx):

<NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "E:/home/georgedillon.com"
ServerName georgedillon.com
ErrorLog "E:/home/georgedillon.com/logs/error.log"
CustomLog "E:/home/georgedillon.com/logs/localaccess.log" common
ScriptAlias /cgi-bin/ "E:/home/georgedillon.com/cgi-bin/"
</VirtualHost>
<Directory "E:/home/georgedillon.com/cgi-bin">
Options +ExecCGI
</Directory>


<NameVirtualHost 127.0.0.2
<VirtualHost 127.0.0.2>
DocumentRoot "E:/home/stevenberkoff.com"
ServerName stevenberkoff.com
ErrorLog "E:/home/stevenberkoff.com/logs/error.log"
CustomLog "E:/home/stevenberkoff.com/logs/localaccess.log" common
ScriptAlias /cgi-bin/ "E:/home/stevenberkoff.com/cgi-bin/"
</VirtualHost>
<Directory "E:/home/stevenberkoff.com/cgi-bin">
Options +ExecCGI
</Directory>

IMPORTANT: The 2 log files ErrorLog and CustomLog MUST EXIST for EVERY website listed here, or Apache will crash when it starts

10. Save the file and close the text editor

TESTING:

1. Right click on the Apache Service Monitor icon in the Taskbar and click ‘Start’
2. If you have followed the steps above correctly, in the upper (Service Status) window the icon next to Apache 2.2 will turn green and in the lower window you will see the message “The Apache2.2 service has started.”
3. Open a browser and type in the address bar http://127.0.0.1/ and your website will appear
4. IF Apache does not start correctly, then check that you have followed all the steps above accurately, that all paths are correct and that the log files exist for each virtual host.

Spot any mistakes? We are always open in improving our ways so feel free to comment below!

3 Comments

  1. This is a good list. It is one of the things you usually don’t think about once you’ve done it, but that you need the next time you move the server. The only thing I don’t change is the shtml. How do you handle log rollover?

  2. Looking for a unique (even experimental) system for forex and currency fx trading that works seamlessly with Metatrader 4. Interested in your own recommendations and tools that work at the beginner / intermediate level.
    best forex software

Leave a Comment (links are nofollow)