featuredb

How to Manually Install Apache on Windows

The Apache HTTP Server, commonly referred to as Apache is a web server application notable for playing a key role in the initial growth of the World Wide Web. This tutorial is on how to manually install Apache HTTP Server on Windows 7.

Note: Apache HTTP Server 2.4.9 was the latest version at the time of this writing.

Installation

  1. Go to http://www.apachelounge.com/.
  2. Look for VC10 Win32 in the Downloads page.
  3. Download httpd-2.4.9-win32.zip.
  4. Once download has completed, unzip the file. There should be an Apache24 folder.
  5. Copy the contents of the Apache24 folder to D:\webserver\apache. Create the folder apache if it doesn't exist.
  6. Apache can be installed anywhere on your system, but you will need to change the configuration file paths accordingly.
    Extracted apache files

    Extracted apache files

  7. Download and install the Visual C++ 2010 SP1 from microsoft - http://www.microsoft.com/download/en/details.aspx?id=8328. This is needed by apache to run.

Configure Apache

  1. Open the apache configuration file in D:\webserver\apache\conf\httpd.conf. Here I am using Notepad++ as my preferred text editor.
  2. Find the ServerRoot directive and change it to:
    ServerRoot "D:/webserver/apache"
  3. Find #LoadModule rewrite_module modules/mod_rewrite.so and remove the # symbol to uncomment it:
    LoadModule rewrite_module modules/mod_rewrite.so
    This will enable pretty URLS which most PHP apps, like WordPress, need.

    This will enable pretty URLS which most PHP apps, like WordPress, need.

  4. Still in our text editor, find the ServerName directive:

    #ServerName www.example.com:80

    And change it to:

    ServerName localhost:80

  5. Find the DocumentRoot directive:

    DocumentRoot "c:/Apache24/htdocs"

    Change it to:

    DocumentRoot "D:/webserver/htdocs"

    This tells apache to serve files from this folder.

Note: Please create the folder htdocs if it doesn't exist yet.

  1. Below it change <Directory "D:/Apache24/htdocs"> to <Directory "D:/webserver/htdocs">
  2. Still inside find:

    AllowOverride None

    And change it to:

    AllowOverride All
    apache6

  3. Now that we have finished editing, save the configuration file so we can verify it for correctness. Open windows command line and go to D:\webserver\apache\bin.

Note: A quick way open a command line in a directory is to hold the shift key and right-click an empty space in windows explorer. In the context menu that pops up, click Open command window here.

  1. In the command line type this and hit enter:
    httpd -t
    It should return: Syntax OK

    apache7

Installing and Running the Apache Service

  1. To Install apache as a windows service, type this in the command line and hit enter:
    httpd -k install

Note: If you get an access denied error, run command line as administrator by clicking the Start button, typing "cmd" in the search field, and on the results right click cmd.exe and click run as administrator. Go to the apache/bin directory and install apache service.

Running cmd as Administrator

Running cmd as Administrator

  1. Run apache by typing:
    httpd -k start

    Now apache will run every time you start windows. If you reformat windows in the future, just reinstall VC++ 2010 and reinstall apache as service.

Testing Our Local Web Server

  1. Go to our htdocs folder and create a file named index.html.
  2. Paste this content:
    <!DOCTYPE html>
    <html>
    <body>
    	<p>Hello from Apache!</p>
    </body>
    </html>

    Fire up a browser and type http://localhost. You should see a Hello from Apache! text.

    Apache in action

    Apache in action

Apache Install, Start, Stop, and Uninstall Commands

To run these commands, you must open a command prompt in the D:\webserver\apache\bin directory.

Install Apache windows service:

httpd -k install

Start Apache:

httpd -k start

Stop:

httpd -k stop

Uninstall:

httpd -k uninstall

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php