How to install Apache Server on Windows

Note

Those of you interested in the Apache 2.0.X tutorial, it has been abandon and I will no longer keep it updated, but it can be found here.

Apache 2.2.X

  1. Download & Unpack

    Go to http://www.apache.org/dist/httpd/binaries/win32/ and choose a mirror. You want the latest win32-x86-no_ssl.msi "MSI Installer Package" release.

    My file was named: httpd-2.2.21-win32-x86-no_ssl.msi
    NOTE about finding the download links
    Apache sometimes moves the "quick download" link to the win32 binary. The long way to officially find it is Download > Other files > binaries folder (not the "Binary Releases" info link at the top) > win32 folder > then the latest win32-x86-no_ssl.msi release
  2. Install

    When you install Apache, you'll get a prompt for "Server Information." Here is the settings I used:
    Network Domain: localhost
    Server Name: localhost
    Admin Email: (any email. real or fake)
    
    [checked]: for All Users, on Port 80, as a Service
    
  3. Starting/Stopping Apache

    After installation Apache2 will automatically start. The start icon in the System Tray means it started. The stop icon means the "Monitor Apache Servers" is running, but Apache2 isn't started.

    You can easily start/stop/restart Apache and Apache2 via that icon in your System Tray. If you get "The requested operation has failed!" error while starting apache use the "Test Configuration" shortcut in the Start Menu to find the error (if the text window pops up then closes before you can read it, your config file is fine).
  4. Testing

    Now the ultimate test. To see if it's serving. Open your browser and head to: http://127.0.0.1/ or http://localhost/

    If it shows the It works! you have your server software installed and running.
  5. Making Apache point to your files

    Using Notepad open C:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf (in the start-menu there should also be a "Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File" shortcut) and search for DocumentRoot. Change it from something like DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" to the location where your HTML files and site are located. In my case: DocumentRoot "C:/public_html"
    NOTE
    The first time i installed Apache2, i accidentally changed ServerRoot. Make sure you change the correct line which is DocumentRoot and which is down about line 175.
    Then scroll down about one page and change: <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"> to point to the same location you set DocumentRoot to in the last step.

    Restart apache to make the changes take effect

Comments

Hey there, great tutorial! Everything went smooth as silk except for one little hiccup, and I'd like to post the solution for anyone else who might have this problem.

After installing Apache successfully, when trying to edit and save the httpd.conf, an error pops up saying something like:

Cannot create the C:\Program files\apache Software Foundation\apache2.2\conf\httpd.conf file
Make sure the path and file name are correct

The reason this happens is because by default users do not have write permissions for this file. All you have to do is right click on httpd.conf, click properties, select the security tab, click edit, select users, and then check Full Control - Allow.

Hope this helps! For reference I'm using Windows Vista (yes, I know I know, don't get me started...)

In Windows 7, setting permissions and taking ownership of the file did not let me save it. I had to "run Notepad as administrator' even though I was logged on as an administrator. Then it worked normally. I really hate Win7.

I was getting the pop up window that Apache Server couldn't start; "The requested operation has failed!" yet the "Test Configuration" text window popped up quickly and went away with no configuration errors.

After some messing around, and per my exiting Skype, Apache worked! By default Skype and Apache both want to use Port 80...

You can change Skype to not use port 80 by clicking Tools > Options > Advanced > Connection. Uncheck "Use port 80 and 443 as alternatives for incoming connections."

It worked for me! :-)

Same issue for me with Skype! Thanks for the tip!! :-)

[admin edit]
To save space, I'm pruning multiple replies thank you replies. Sufficient to say there have been MANY people who found this info use. Really appreciate the original poster sharing this info.

I can't seem to get the server to recognize changes to the httpd.conf file... I've changed the value of DocumentRoot as below:

DocumentRoot "D:/webroot"

(And updated the corresponding entry to match.)

However, no matter how many times I've tried this the server still looks for files in the default location of "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs". I've tried editing with various different programs. Have ensured that the server is stopped when I make the changes, tried with and without a trailing "/", and using a "\" instead of "/". Every so often when I open the file, it seems to have reverted to the original settings, but I haven't found a patten to what makes that happen.

Also installed AppacheConf and pointed it at the httpd.conf file... Whenever I inspect the configuration from there, the settings reflect the default htdocs location, but when I open the same file using notepad or pspad, I see the settings I've noted at the top.

Running Windows 7 Home Premium (x64). Appache is version 2.2.

Any suggestions? I'm pulling my hair out! (What's left of it, anyway.)

Corey

Are you sure positive you are editing the right file? because there is a httpd.conf (which Win7 might hide the .conf extension) and there is also generally a httpd-sample.conf or httpd-default.conf or other very-similarly named files in the same folder.

did you try opening the config file with the shortcut in the start menu? Also search all the way through the file and make sure there isn't more than one occurrence of DocumentRoot (apache will use the last one it finds in a file while you might be editing the first one).

Windows XP, Vista, and Win7:
Navigate to windows control panel, and find an item of "folder options" or something similar.

Open it, and go to "View", here you must unselect "Hide extensions for known file types".

It is also worth mentioning that I had to give myself admin rights to modify file in the folder of the httpd.conf file for me to edit it. ( I have Win7 pro)

I thank you for the newbie-friendly instructions. The installation went smoothly and Apache works as expected. However the SSI does not work for my shtml files. The browser (Firefox) just shows the page code. What do I do to hhtp.confd to enable SSI?

Thanks,
Len Stephan

you need to do two things to enable SSI

1) The first step, you need to add Includes to the end of your main Options line. In httpd.conf look inside the <Directory "C:/public_html"> folder settings, there should be a line like Options Indexes FollowSymLinks (about line 219) and you want to add Includes to the end so it looks similar to Options Indexes FollowSymLinks Includes

2) The second step is to uncomment two lines under the mime_module section. So:
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
becomes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Restart Apache and SSI should be enabled for .shtml files.

hey, I have performed all the steps for the installation but I seem to be having problems while trying to get the it works message to display, when I type in http://localhost/ in the address bar it says it could not find the address. But when I try pinging it from the command prompt it works fine. I have tried everything, I even tried clearing the browser cache. Any suggestions with regard to this problem are welcome...

I would guess you don't have an index file in your DocumentRoot directory and that Apache is not set to list the files available by default.

As soon as I move the DocumentRoot from the htdocs location, I get a 403 Access Denied error. I'm running Apache on Windows Server 2008, and it was working before I tried to sort out password protection using .htaccess etc. I uninstalled Apache, and deleted all related files I could find but it keeps coming back with the same error!

Any ideas?

what happens if you try to directly access a file? eg; http://localhost/index.html - does that also give a 403? if directly accessing a file works, then the problem is related to DirectoryIndex not having the correct "default" files after it that you want apache to look for when you access a directory (eg; DirectoryIndex index.php index.html) or Options needs +Indexes added to it if you want apache to list the files if a DirectoryIndex file isn't found (by default I think it will 403 now instead of listing the files)

Thanks for your valuable tips. now will you please tell me the procedure to run a jsp program on this web server?

No, that is not normal and I'm not sure it's even possible (without multiple IPs mapped). Both apache and IIS run on port 80 by default and whichever one starts first should "lock" the port 80 and prevent the other program from serving on it. Are you sure 127.0.0.1 is displaying an IIS message and not some browser created message? (they do look alike in Internet Explorer).