How to Install Apache on Windows

This guide provides a straightforward, step-by-step walkthrough for installing and configuring the Apache HTTP Server on a Windows operating system. You will learn how to download the correct binaries, configure Apache as a Windows service, and test your installation to ensure your local web server is running correctly.

Step 1: Download the Apache Binaries

Because the Apache Software Foundation does not provide official binary installers for Windows, you need to download a compiled version from a trusted third-party vendor.

  1. Visit the official Apache Lounge website (apachelounge.com), which is the widely recommended source for Windows binaries.
  2. Navigate to the downloads section and select the latest Apache 2.4 Win64 ZIP file.
  3. Ensure you have the required Visual C++ Redistributable installed on your system, which is typically linked on the same download page.

Step 2: Extract the Files

Once the ZIP file has finished downloading, you need to place the files in their permanent location on your hard drive.

  1. Right-click the downloaded ZIP folder and select Extract All.
  2. Set the extraction path to the root of your C drive: C:\.
  3. After extraction, you should have a folder structure that looks like C:\Apache24.

Note: While you can install Apache to a different directory, C:\Apache24 is the default configuration path. Installing it here saves you from editing multiple lines of configuration files later.

Step 3: Configure the Apache Server

Before running Apache, you need to make a quick adjustment to the configuration file to ensure it recognizes your server.

  1. Open the folder C:\Apache24\conf and locate the httpd.conf file.
  2. Open httpd.conf using a text editor like Notepad or Notepad++.
  3. Scroll down or search for the ServerName directive (around line 225).
  4. Remove the # symbol at the beginning of the line to uncomment it, and change it to: ServerName localhost:80
  5. Save and close the file.

Step 4: Install Apache as a Windows Service

Installing Apache as a service ensures that it runs automatically in the background when your computer boots up.

  1. Click the Windows Start menu, type cmd, right-click on Command Prompt, and select Run as administrator.
  2. Change your directory to the Apache bin folder by typing the following command and pressing Enter: cd C:\Apache24\bin
  3. Install the service by entering: httpd.exe -k install
  4. If successful, you will see a message stating that the “Apache2.4” service has been successfully installed.

Step 5: Start the Server and Verify Installation

With the service installed, you can now start your web server and test it using a web browser.

  1. In the same administrator command prompt, start the Apache service by running: httpd.exe -k start
  2. Open any web browser and type http://localhost into the address bar, then press Enter.
  3. If everything is configured correctly, your browser will display a simple web page that says “It works!”