How to Install Apache 2.2 on Windows Vista

Avoid Setup Errors, Port 80 Binding Errors, etc


How to Install Apache 2.2 on Windows Vista

by Christopher Heng, thesitewizard.com

Although I have written a number of articles on installing Apache 2.2, 2.0 and 1.3 on Windows in the past, they were designed for installation on Windows XP and earlier. With Windows Vista now being used by more developers, people are finding that getting Apache to install successfully, let alone work, on Vista is not trivial. This tutorial deals with how you can set up Apache 2.2 on Windows Vista so that it will not only work properly, but is also easy to configure and to update.

Preliminary Notes

Make Sure Nothing is Listening on Port 80

The first thing you must do before you try to install Apache 2.2 on Vista is to make sure that there are no other programs listening on port 80 of your computer. Very loosely, in layman's language, "Port 80" is just the special interface on the computer that a web server monitors. When a browser tries to connect to a website located on the server, it will by default connect to port 80. When Apache is installed on a computer, it monitors port 80, that is, it "listens on port 80". If something else is already listening on port 80, your installation of Apache will fail.

How to Find Out If What Service or Program is Listening on Port 80

There are probably many ways to discover if there is any program monitoring port 80. One way is to use the "netstat" program from the command prompt.

To open a command prompt in Vista, click the Windows button (ie, the Start menu, although it's no longer labelled as such), type "cmd" into the empty field, and hit the ENTER key. A black command prompt window will open.

In that window, type "netstat -ao" (without the quotation marks) and hit ENTER. (Note: the "o" in "-ao" is the letter "o".) If your window is too small for you to see all the lines, you can scroll up (with the scroll bar on the right side of the window) to view the entire list.

Look for any line that has "TCP" in the first column (the "Proto" column), a string of characters that end in ":80" in the "Local Address" column (typically "0.0.0.0:80"), and "LISTENING" in the "State" column. If so, it means that you have some program already listening on port 80. To find out which program, note the number in the PID column of that line.

Now hit Ctrl+Shift+ESC on your keyboard. That is, hold down the Ctrl and Shift key on your keyboard, and press the ESC key. The Windows Task Manager should open. Click the "Services" tab in that window. Look for a matching PID to find the name of the service that is listening on that port. That is, scroll down the list until you find a line that has the same PID. Then look at the name of the service on the left.

Hopefully, the name of the service is informative enough for you to track down the program that currently uses that port. If so, start up that program (eg from your Start menu) and look for a way to stop it from listening on port 80 in its Options. Programs that listen to port 80 include the IIS (a web server from Microsoft) and Skype. (You can stop Skype from listening on port 80 from its Advanced Options.)

If you have already tried installing Apache once before, make sure you uninstall it and then go through your "Program Files" folder and delete any remaining Apache files. If you don't, your new installation won't work correctly.

When you've finished with the above, close the command prompt window and the Windows Task Manager. (Just hit the "X" close button on those windows.)

Steps to Installing Apache 2.2 on Windows Vista

  1. Download Apache 2.2

    If you haven't got Apache 2.2, download it from the Apache site. Since this guide deals with the 2.2.x series, simply click the "Download" link under the 2.2.x (where "x" is some number) section. You will be brought to the download page. Scroll down and look for one of the "Win32 Binary" links. I used the "Win32 Binary without crypto (no mod_ssl) (MSI Installer)" link for my purposes. Make sure that you get the 2.2.x version (where "x" is some number) and not the 2.0.x (again, where "x" stands for some number) binary, otherwise your installation procedure will not match those given in this guide.

    Save the file on your desktop. (Technically speaking, you can save it anywhere you like, but I shall assume that you saved it on your desktop in this tutorial. It's best that you save it on your desktop if you're following this tutorial, otherwise some of the command lines that you will use below won't work correctly.)

  2. Run the Installer as Administrator

    Before you run the installer, you will need to open the command prompt window as administrator. To do this, click the Start menu button, the "All Programs" menu item, the "Accessories" folder, and look for the item "Command Prompt". Do NOT click it, or you'll be running the command prompt with normal rights (even if you're logged in as an administrator). Instead, right click "Command Prompt" (click with the right mouse button), and click the "Run as administrator" item in the menu that pops out.

    Vista will prompt you with a dialog box entitled "User Account Control". Click the "Continue" button. A command prompt window will open. This command prompt window has the title "Administrator Command Prompt" instead of the normal "Command Prompt" or "c:\Windows\system32\cmd.exe".

    (If you do not see the title "Administrator Command Prompt" on your command prompt window, it means you did it wrongly. Close the command prompt window and redo this step, this time following every step of my instructions.)

    Type the following line into the window followed by the ENTER key. Include all the quotation marks and the percent sign. (That is, type it literally as given.)

    cd "%USERPROFILE%\desktop"

    This command switches you to your desktop directory, where you have saved your Apache installer. For example, if your Vista username is "chris", you should now be in the "c:\Users\chris\desktop" directory. Next, you will need to run the Apache installer from this command line. The actual name of the Apache installer file is different depending on the version you downloaded. For example, at the time I wrote this article, the file I downloaded was called "apache_2.2.10-win32-x86-no_ssl.exe". Later versions may, instead, have an ".msi" extension, like "apache_2.2.11-win32-x86-no_ssl.msi", although you may not be able to see any file extension, depending on how you have configured Vista.

    Now run the installer by typing the full name of the file (including the extension, especially if it has an ".msi" extension) on the command line and hitting ENTER. If you are too lazy to type the full filename, are a slow typist or simply afraid that you'll give the wrong filename, a shortcut is to type "apache" and hit the TAB key. The command line shell (the Command Prompt) will immediately try to complete the filename for you. If you have many files on your desktop starting with the word "apache", just keep hitting the TAB key until Command Prompt auto-completes the correct filename for you.

    When the correct filename appears, hit ENTER to run the installer. The Apache installation wizard will then pop up.

  3. How to Set Up Apache with the Installation Wizard on Vista

    Follow the installer's instructions on setting up the web server (that is, read the information displayed in each dialog box, and click the necessary buttons). For the most part, installing is pretty straightforward. Don't worry, the not-so-straightforward portions are described in detail in the next few paragraphs.

    When you come to the "Server Information" window, enter "localhost" (without the quotation marks) in both the "Network Domain" and "Server Name" fields. In the "Administrator's Email Address" field, enter whatever email address you wish. In theory, this information is used by the installer to create a default configuration file for your web server. (In practice, the installer seems to ignore whatever you enter here. But you should still enter what I said earlier, just in case the installer has been fixed in the version you use.) You can easily modify this in your configuration file later if you change your mind.

    Leave the default option "for All Users, on Port 80, as a Service" as it is. When you're satisfied with what you've entered, click the "Next" button.

    When you're presented with the "Setup Type" screen, leave the default setting of "Typical" and click "Next". You'll be asked for the location to install Apache. Leave it at the default of "c:\Program Files\Apache Software Foundation\Apache 2.2\". I will assume that you've installed to this location in the rest of this article. Click "Next".

    When the "Ready to Install the Program" window appears, click the "Install" button. The setup utility will proceed to set up Apache on your machine.

    When the installer is done, click the "Finish" button to dismiss it. There should be no error messages or error windows. (If you get any errors, it probably means that you did not rigorously follow my procedure in this guide. To solve it, uninstall everything and start again.)

    Do not close the administrator command prompt window that you opened earlier. You'll need it again later.

  4. How to Start and Stop the Apache Service: Introducing The Apache Monitor

    Once you've finished all the above steps, you should be able to see a new icon in your system tray. This is the Apache Monitor. If you're not sure which icon in your tray is the Apache monitor, move your mouse button over each icon and wait for the tooltip to appear. The Apache Monitor should give a tooltip of "Running all Apache services" after you have successfully installed the program.

    Doubleclick the icon to open up the Apache Monitor program. A window, "Apache Service Monitor", will appear. This program allows you to start and stop the Apache web server on your machine. By default, the setup utility starts the Apache web server. If you want to the server to run only when you actually test your website on your computer, you can use the monitor to stop and start it.

    At the risk of stating the obvious, clicking the "Stop" button will stop the Apache web server service. The "Start" button starts it. If you make a change to the Apache configuration file (see later in this article), you will need to hit the "Restart" button to reload the Apache service, so that the server will reread the configuration file. When you're through playing with the buttons, click the "OK" button (not the "Exit" button) to return the Monitor to the system tray. If you have accidentally hit the "Exit" button and found that you've killed the Monitor, you can restart it again from your Start menu. (Type "monitor apache servers" in the Start menu search field.)

    If a button is disabled, it means that it's not relevant to the current situation. For example, if the Apache web server is already running, the "Start" button will be disabled. You can pretty much ignore the other buttons.

  5. Interim Test

    At this point, the Apache web server is fully functional. To make sure that the server is properly set up, start up your web browser, and go to the address "http://localhost/". If you see a simple web page with the words "It works!", it means that the server installation was successful.

How to Make the Apache Web Server Convenient to Use on Windows Vista

Even though Apache may now be properly installed on your system and running smoothly, in its current state, it is not convenient to configure or even copy your website files to it.

The problem is that the current Windows version of Apache 2.2 installer (version 2.2.10 at the time I wrote this article) was not really written with Vista in mind. As such, things that you frequently need to modify, like the configuration file and the web server files, are located in the "c:\Program Files\Apache Software Foundation\Apache 2.2\" folder. In Vista, the "Program Files" folder and its descendants are protected folders that programs can access only if they are run with administrator privileges (like we did earlier when we ran the Command Prompt as administrator).

If we leave things in this state, the only way that you can configure Apache is to run your editor as administrator. And when you need to copy your website's files to your local server, you'll need to do it when running as administrator. All in all, this makes things very troublesome for the web developer.

As such, until the Apache developers update the server to directly support Vista installations, you may want to do the following to make your life easier.

  1. Create a Folder for Your Apache Configuration and Website Files

    Create a new folder, either on your Desktop or in your Documents folder, called "apache". Actually, it doesn't matter where you create the folder or what you call it. However, for the purpose of this tutorial, I will assume that you created a new empty folder called "apache" on your desktop. That is, if your username is "heng", you will have a new folder called "c:\Users\heng\Desktop\apache".

    (To create a folder, right click your desktop and select "New" from the menu that appears, followed by the "Folder" item in the submenu. Rename the "New Folder" to "apache".)

    Open the folder by doubleclicking it. It should be empty. Leave the window open.

  2. Copy the Conf and Htdocs Folders to Your Private Apache Folder

    Click the start menu followed by the "Computer" item in the menu. This will open an Explorer window. Navigate to "c:\Program Files\Apache Software Foundation\Apache 2.2\" in the usual way you go to different folders on your computer. (That is, doubleclick the C: drive, then the "Program Files" folder, then the "Apache Software Foundation" folder, and finally the "Apache 2.2" folder).

    Look for the folder "conf". Right click the folder and select "Copy" from the menu that appears. Switch to the "apache" window that you opened in the previous step. Right click in the empty space in that window and select "Paste". Do the same for the "htdocs" folders as well. Do NOT drag and drop them. Copy and paste the folders or you will end up with folders and files having the wrong permissions.

    By the end of this step, you should have two copies of the "conf" and "htdocs" folders: one in your "Apache 2.2" Program Files folder, and one in your Desktop "apache" folder.

  3. Delete the Original Conf and Htdocs Folders

    Open the Apache Monitor by doubleclicking on its system tray icon. Click the "Stop" button to stop the service. When the service has stopped, you will see a message in the lower window "The Apache2.2 service has stopped". Click the "OK" button.

    Now switch back to the first window, the one pointing to "c:\Program Files\Apache Software Foundation\Apache 2.2\". Right click the "conf" folder and click "Delete" from the menu that appears. You will be asked to confirm in triplicate (I'm not kidding). That is, a dialog box will appear asking if you are sure that you want to move the folder to the Recycle Bin. Click "Yes" to the prompt that appears. Another dialog box, with the title "Destination Folder Access Denied" will open, asking you to confirm the operation. Click "Continue". Yet another window, the "User Account Control" will appear, again asking for your permission to continue. Click "Continue" again.

    Repeat the procedure with the "htdocs" folder.

  4. Create a Symbolic Link to Your Private Apache Folder

    Switch to the Administrator Command Prompt that you opened earlier.

    Type the following line into the "Administrator Command Prompt" window and hit the ENTER key.

    cd "c:\Program Files\Apache Software Foundation\Apache 2.2\"

    Be sure to type the opening and closing quotation marks (yes, the quotes are needed). The command will bring you into the Apache folder. To make sure you're in the right folder, type "dir" (without the quotes) followed by the ENTER key. You should see the same files and folders that you saw earlier in the Explorer window, albeit arranged in a different order.

    Type the following command, followed by the ENTER key. Notice that the command line includes characters like the quotation marks and the percent sign. All the characters are required.

    mklink /D conf "%USERPROFILE%\desktop\apache\conf"

    The shell (command prompt) will print reassuring words to the effect that a symbolic link has been created and where the link points to.

    If you make a mistake creating the symbolic link, so that it points to the wrong location, delete it by typing "rd conf" followed by the ENTER key. Then try again. Note that my above command line assumes that you have created a folder called "apache" on your desktop, as I mentioned earlier.

    Finally, create a symbolic link for the htdocs directory.

    mklink /D htdocs "%USERPROFILE%\desktop\apache\htdocs"

    To make sure that all is well, doubleclick the Apache Monitor icon again, and start the web server service. (That is, click the "Start" button in the Monitor window.) Then open your web browser and surf to "http://localhost/". The "It Works!" web page should appear. If "It Works" does not appear, and you get a directory listing of some other directory, it means that your "htdocs" link is pointing to the wrong location. Delete the existing link with "rd htdocs" in the Administrator Command Prompt and try again.

Using Apache on Vista: Basic Getting Started Guide

How to Add PHP and Perl to Your Apache Web Server

Out of the box, Apache does not contain support for PHP or Perl. If you want your server to support PHP scripts, please see the article How to Install and Configure PHP 5 to Run with Apache on Windows.

I also have an older article How to Add Perl CGI Script Support to Your Apache Server on Windows that deals with adding Perl to Apache. That article was written for Apache 1.x, and is thus probably not very relevant to the 2.x series. I'll eventually get round to updating the article for Apache 2 on Vista, but in the meantime, if you're really stuck, it may provide some tips on what to look for when installing Perl.

(Note: If you want to be notified when these articles are updated or when new articles are published, please subscribe to thesitewizard.com's news feed. Instructions on how to do this can be found in my FAQ How to Subscribe to or Read News Feeds. Subscription is free, of course.)

Conclusion

Congratulations! You have now not only installed Apache 2.2.x successfully on Windows Vista, you've also configured it and made the overall use of Apache very much easier so that each time you modify its settings or update your website, you don't have to face multiple UAC prompts from Vista. And you didn't even have to permanently disable UAC (which, in spite of its detractors, has its uses) to accomplish it.

This article can be found at https://www.thesitewizard.com/apache/install-apache-on-vista.shtml

Copyright © 2008-2018 by Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from https://www.thesitewizard.com/.

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to thesitewizard.com newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml. You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Articles

New Articles

How to Link to This Page

It will appear on your page as:

How to Install Apache 2.2 on Windows Vista





Home
Donate
Contact
Link to Us
No Spam Policy
Privacy Policy
Topics
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Domains
Web Hosting
Blogging
JavaScripts
PHP
Perl / CGI
HTML
CSS
.htaccess / Apache
Newsletters
General
Seasonal
Reviews
FAQs
Wizards

 

 
Free webmasters and programmers resources, scripts and tutorials
 
HowtoHaven.com: Free How-To Guides
 
Site Design Tips at thesitewizard.com
Find this site useful?
Please link to us.