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
- Go to http://www.apachelounge.com/.
- Look for VC10 Win32 in the Downloads page.
- Download httpd-2.4.9-win32.zip.
- Once download has completed, unzip the file. There should be an Apache24 folder.
- Copy the contents of the Apache24 folder to D:\webserver\apache. Create the folder apache if it doesn’t exist.
- Apache can be installed anywhere on your system, but you will need to change the configuration file paths accordingly.
- 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
- Open the apache configuration file in D:\webserver\apache\conf\httpd.conf. Here I am using Notepad++ as my preferred text editor.
- Find the ServerRoot directive and change it to:
ServerRoot "D:/webserver/apache"
- Find #LoadModule rewrite_module modules/mod_rewrite.so and remove the # symbol to uncomment it:
LoadModule rewrite_module modules/mod_rewrite.so
- Still in our text editor, find the ServerName directive:
#ServerName www.example.com:80
And change it to:
ServerName localhost:80
- 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.
- Below it change <Directory “D:/Apache24/htdocs”> to <Directory “D:/webserver/htdocs”>
- Still inside
find: AllowOverride None
And change it to:
- 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.
Installing and Running the Apache Service
- 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.
- 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
- Go to our htdocs folder and create a file named index.html.
- 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 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