How to Install Apache 2.2 in Windows

12 September 2008

Apache Web Server Apache is a powerful open source web server which widely used by many hosting providers around the world. This article will guide you how to install latest version of Apache 2.2.x series in local computer with Windows operating system.

This article assumes that you already read the preceeding article:
How to Install Apache, PHP and MySQL in Windows – Preparation

Installation Process
  • Run the downloaded msi file and follow the setup instructions.
  • Fill the Network Domain with: localhost
  • Fill the Server Name with: 127.0.0.1
    For who do not know, 127.0.0.1 is the standard IP address used for a loopback network connection. This means that if you try to connect to 127.0.0.1, you are immediately looped back to your own machine.
  • Fill the Email Administrator Address with your any email address. This field cannot be left blank.
  • Mark for Run as service for All Users
    This setting will have conflict possibility with the running IIS web server. Do not worry about this right now since we will fix this problem as soon as finished the installation process.
  • Choose Typical setup type.
  • Change the installation folder for Apache HTTP Server to C:\apache2 for easier maintenance later. Please note that folder name with spaces like the default folder C:\Apache Software Foundation somehow will cause some problem in PHP configuration later.
  • Continue the installation process. You may find your screen blinking during installation because the process will start the Apache service automatically.
Apache Configuration

Changing Port

To avoid conflict with Windows IIS web server then we have to run Apache in different port other than port 80. We can make it to run in port 8080 which assigned by IANA (Internet Assigned Numbers Authority) as http alternate.

  • Go to folder c:\apache2\conf and open file httpd.conf with your text editor.
  • Find the word Listen 80 and change it to Listen 8080
  • Find the word #ServerName 127.0.0.1:80 then remove the mark and change the line to become ServerName 127.0.0.1:8080

mod_rewrite

mod_rewrite is a module which provides a rule-based rewriting engine to rewrite requested URLs on the fly. Mostly this module used to change complex URL address to become more simple and search engine friendly.

  • Find the Load Module section then delete the leading # (pound) so the line will read LoadModule rewrite_module modules/mod_rewrite.so.
  • Find the line content DocumentRoot and put the path of htdocs folder. Following this article you can change the line to: DocumentRoot “C:/apache2/htdocs”
  • Find the section like below:

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

Change this section to become:


<Directory>
   Options All
   AllowOverride All
   #Order deny,allow
   #Deny from all
</Directory>


Testing

Restart your Apache service by using Monitor Apache Server application which you can find at the task bar. Alternatively you can open Settings | Control Panel | Administrative Tools | Services and do restart the Apache service in the list.

You can test your installation by typing http://localhost:8080 in your browser. If your browser showed: “If you can see this, it means that the installation of the Apache web server software on this system was successful“ or “It works“, then your installation was successful.

Now you can put your folder or html files in c:\apache2\htdocs. Browse your web using this address http://localhost:8080/[files or folder].

Next article: How to Install MySQL 5.0 in Apache 2.2 for Windows.