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.
For older versions of WAMP, here are the articles.
Steps to install Apache on Windows as development machine
Here is a list of Apache HTTP server related pages:
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.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.
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:
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"
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">
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.
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.
Copyright © 2017 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.