Custom Search
 


How to install Apache 2.x web server on Windows



Apache is the most popular web server. This article illustrates how to install it on Windows (XP, Vista, Windows 7) as part of a WAMP (Windows, Apache, MySQL, PHP) web development environment.

The order of installation for WAMP environment

To make installation a smooth process for a WAMP development environment, we want to install these components in the following order.

1. Install MySQL 5.x
2. Install Apache 2.x
3. Install PHP 5.x

For older versions of WAMP, here are the articles.

1. Install MySQL 4.x
2. Install Apache 1.3
3. Install PHP 4.x

Steps to install Apache on Windows as development machine

Here is a list of Apache HTTP server related pages:

  1. Apache HTTP server home page
  2. Apache HTTP server download page
  3. Apache for Windows documentation page

Step 1: Download Apache 2.2

In this article, we use Apache 2.2.14 to demonstrate the installation process. Other 2.x versions have very similar installation steps.

(1) Go to Archived Win32 binaries download page here http://archive.apache.org/dist/httpd/binaries/win32/

(2) Download Apache 2.2.14 msi installer.

Here is the direct download link apache_2.2.14-win32-x86-no_ssl.msi

Step 2: Verify the downloaded file for integrity

Apache download comes with a MD5 hash value. This hash value is a Checksum value that can be used to verify data and file integrity.

Screenshot below shows the Apache installation file was verified by freeware HashCalc.

Checksum calculated by HashCalc:

As we see above, the MD5 checksum value by Apache.org is the same as the one calculated by HashCalc, which means the file is in good shape and can be trusted.

Step 3: Start installation

Double click the installation file. The installation should start straight away. Here are 9 screenshots.

3.1 Welcome

3.2 License Agreement

3.3 Read First

3.4 Server Information

This step needs a bit explanation. Add localhost to both Network Domain and Server Name box. Administrator's Email Address can be anything you like. These info are used for Apache configuration file but you can change them after the installation.

Next, select the first radio button as recommended. This way, Apache will be running as a Windows Service. See Step 6 below for more info about how to start, stop, restart Apache.

3.5 Setup Type

Choose Typical as the setup type.

3.6 Destination Folder

You can leave the default installation folder as is.

3.7 Ready to install

3.8 Installing in progress

3.9 Completed successfully

Step 4: Test your installation

After install, open web browser and type either of the following URLs into your browser's address bar and hit Enter key.

  1. http://localhost
  2. http://127.0.0.1
  3. http://169.254.32.57 or 192.168.0.1 (eg. local network IP address)

If Apache has been installed correctly, you should see a success message opened in your web browser, as shown below.

The text actually comes from the index.html file in this directory C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ which is the default document root directory after Apache is first installed. The document root directory can be changed in Apache configuration file. See Step 5 below.

Note: http://169.254.32.57 could be your local machine's auto assigned IP that Microsoft has reserved (addresses 169.254.00 to 169.254.255.255).

If you use a router which sets up a LAN (Local Area Network), the router can assign an internal IP. For example, Linksys assumes a default internal IP address of 192.168.0.1

To find out your computer's IP address, open a command line window and run ipconfig command:

  • Click Start
  • Click Run
  • In the Run command box, type cmd and hit OK

    Run command

  • When command line window is opened, type ipconfig and hit Enter key.

    Run ipconfig command

Step 5: Edit the Apache httpd.conf Configuration File

Apache Configuration File is located at C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf. It can also be opened from the Start menu as below.

Make sure you change the httpd.conf file according to the screenshots shown in the following section.

5.1 Change your document root directory to a more meaningful one.

Inside the configuration file, DocumentRoot is the directory out of which Appache executes web documents, eg. PHP, HTML, etc. It's the directory where your PHP or other web page files are placed into.

1. Commented out DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
2. and then added DocumentRoot "C:/test"

So, all my php files will be located in a folder named as test on my C drive.

3. Commented out <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
4. and then added <Directory "C:\test">

5.2 Add PHP file type into DirectoryIndex

Add the default document file names that Apache will run if we don't type its filename in web browser.

Note: for this article series, we will install PHP next. How to install PHP5 server-side scripting language on Windows

Edit the line as below shows, ie., DirectoryIndex index.html index.htm index.php

5.3 If you need to rewrite URLs on your site, enable the mod_rewrite module.

Web pages can pass variables in URLs and this is known as dynamic URLs. To make these URLs search engine and user friendly, we often change dynamic URLs to static URLs. This change is managed by the URL rewrite module.

To enable the URL rewrite, follow these 2 steps.

  • Find the line of text shown below and remove the hash # at the beginning of the line.

    #LoadModule rewrite_module modules/mod_rewrite.so

    Here is how it looks after the change is made.

  • Change AllowOverride None to AllowOverride All inside the DocumentRoot Directory Directive.

    In our case, it is inside <Directory "C:\test"> Directive.

    Here is how it looks after the change is made.

If you need to modify Hosts file, please note that Windows Vista and Windows 7 have stricter security mechanism that makes changing the hosts file a lot harder. Please refer to Microsoft Knowledge Base article http://support.microsoft.com/kb/923947 to see how to modify the Hosts file in Windows Vista and Windows 7.

Step 6: Restart Apache

After changing Apache configuration file, remember restart Apache Server so that these changes will take effect.

To start, stop, and restart Apache Server, do this: Start -> Programs -> Apache HTTP Server -> Control Apache Server.

If Control Apache Server menu is not available. You can start, stop, and restart Apache by using Microsoft Management Console for Windows Services.

Start -> Settings -> Control Panel -> Administrative Tools -> Services

By using Windows Services, you can Start, Stop, and Restart Apache from Microsoft Management Console. See screenshot below. Selecting Apache as a Windows service will make it automatically start when your computer starts up, and to keep Apache running when you log-off.

Happy Installing!


Copyright© GeeksEngine.com



Related Articles:

1.Steps to install PHP 5.x on Windows as a development machine
2.How to connect two different versions of MySQL server on the same computer
3.How to configure MySQL server 5.1 on Windows
4.How to install MySQL server 5.1 on Windows with screenshots
5.Five ways to create include path for PHP
6.How to use Date and Time data as integer value in PHP and MySQL
7.How to use Apache Virtual Host to run multiple local websites on Windows
8.Install all PEAR packages by yourself
9.How to install PEAR on Windows
10.How to use PHP and Microsoft SMTP Virtual Server to send emails
11.How to install PHP server-side scripting language on Windows
12.How to install Apache 1.3 web server on Windows
13.How to install two different versions of MySQL server on the same PC
14.How to configure MySQL server 4.1 on Windows
15.How to install MySQL server 4.1 on Windows with screenshots
16.Export Northwind Access database to MySQL via ODBC


Other Recent Articles from the WAMP & LAMP category:

1.How to install MySQL Server 8 on Windows
2.How to resolve Apache web server port 80 access problem
3.The free tools I use to build PHP and MySQL websites
4.Steps to install PHP 5.x on Windows as a development machine
5.How to connect two different versions of MySQL server on the same computer
6.How to configure MySQL server 5.1 on Windows
7.How to install MySQL server 5.1 on Windows with screenshots
8.How to upgrade from PHP4 to PHP5
9.How to load time zone data for MySQL on Windows
10.How to use Apache Virtual Host to run multiple local websites on Windows
11.Install all PEAR packages by yourself
12.How to install PEAR on Windows
13.How to use PHP and Microsoft SMTP Virtual Server to send emails
14.How to install PHP server-side scripting language on Windows
15.How to install Apache 1.3 web server on Windows
16.How to install two different versions of MySQL server on the same PC
17.How to configure MySQL server 4.1 on Windows
18.How to install MySQL server 4.1 on Windows with screenshots
19.How to set up DSN in ODBC Data Source Administrator on Windows

Copyright © 2024 GeeksEngine.com. All Rights Reserved.

This website is hosted by HostGator.

No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it.

 
Home | Feedback | Terms of Use | Privacy Policy