How to Install Apache Web Server on Vista – and Avoid Problems!

By smittysblog

Ok, we all know Vista is a pain, but sometimes we gotta use it anyway. If you want to install Apache on Vista, hopefully these step by step instructions will help save you some of the brain damage I went through.

Thanks to other forums, in particular to:
http://senese.wordpress.com/2007/06/06/installing-apache-on-windows-vista/

Even after helpful forums, I still ran into some issues that I hoped I could clarify for others. There’s one remaining issue I haven’t been able to solve, and will post if I can fix it:

I can’t get Apache to listen on port 80. I get an error during install (in the command prompt which goes away) indicating that it can’t allocate port 80, but it doesn’t seem to post the details in the error logs I can view later. I’ve looked using the command “netstat –ao”, and there does not appear to be any applications bound to port 80. The only thing I can figure is something with my Vista firewall – just out of time and need to get some stuff done, so using another port number: 8080.


In any case, here’s the steps I used to succesfully install Apache 2.2 on Vista Home Basic:
I. First uninstall old installations of Apache Server. 1. There’s a few ways to run the unistall:

a. Re-run the Apache installer. It will go into unistall mode.

b. Start > Control Panel > Programs and Features

2. Delete remaining installation files.
I really strongly recommend deleting old files that Vista probably did not remove during the unistall. Delete the whole directory “Apache Software Foundation”.

a. It turns out this is a pain due to Vista permissions on the “Program Files” folder where Apache installs by default.

b. Run the command prompt in administrator mode (this is critical) by right clicking on Start>All Programs>Accessories>Command Prompt and “run as administrator”

c. There may be a much easier/smarter way to do this, but I had to go to each sub directory within “Apache Software Foundation” and “del *.*” then “cd ..” and then “rd ‘directory-name’” to get everything removed. Yes, it is a pain.

II. Now do a fresh install of Apache Web Server as follows:

1. Stop any other services that use port 80. Skype and IIS would be two examples. Set them up to use other ports. In Skype, go to Advanced Options > Connection and uncheck Use Port 80.

a. I used “netstat –ao” in the Command Prompt to show the process bindings to port numbers.

2. If you don’t like the incessant nagging from Vista, stop the User Account Control by Control Panel > User Accounts > Turn User Account Control on or off.
(You can always turn it back on if you want.)

3. Get the most recent version of the Apache Win32 binaries from http://httpd.apache.org/download.cgi and put it on your desktop. Rename it to “apache” (without changing the .msi extension, if that’s showing).

4. As before, run the Command prompt in administrator mode:

a. Right clicking on Start>All Programs>Accessories>Command Prompt and “run as administrator”

5. Change to your desktop folder directory “ cd desktop”

6. Run the installer in administrator mode:

a. At the prompt, type: msiexec /i apache.msi

b. This is critical, or you will have some other security/permissions issues later.

7. Answer the questions in the Apache installer dialogs.

a. I strongly recommend you do NOT use the default directory for the install. I chose “c:\apache”. Otherwise it will put the install in the Program Files directory and you will have serious permissions issues. You will not be able to use the Apache tools on the start menu to edit the configuration files! You will have to edit them manually in administrator mode using the command prompt, which is a pain…

b. If you are running a server live on the Internet, you will have to make sure all your domains are correctly specified. Ie, yourcomputer.yourdomain

c. If you are running a stand alone web server like I am, ( a test server or a development server) you can either leave the domain and server name blank, or you can enter “localserver”.

d. You must specify an email address. I made something up.

e. I first tried choosing to run in manual single user mode and specifiying a different port since I knew I was having issues on this port, but found this didn’t work well. So during my reinstall, I chose the default /all user mode on port 80.

8. After the install completes, I did get an error about port 80, and so I had to edit the Apache config file to change the port number due to the problem I listed at the beginning of this post.

a. I did this via Start Menu> All Programs> Apache HTTP Server 2.2> Configure Apache Server>Edit the Apache httpd Conf iguration File

b. Change the “Listen 80” to “Listen <portnumber>” I used “Listen 8080”.

9. Reboot.

10. Browse to http://localhost. It should say “It works!” If it doesn’t, check your httpd.conf file by going to All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Test Configuration. Follow the directions for fixing the configuration file.

11. I also wanted to setup the default directory for my webpages to something other than where Apache expects them. Who wants their website under the directory htdocs?! Anyway, I wanted them in my own directory elsewhere on my server so I brought up the configuration file as shown in step 13, and edited it as follows .

a. I changed DocumentRoot “C:/apache/htdocs/” to DocumentRoot “C:/localwebsites/siteXYZ/” where my site XYZ’s files were. (OK that really is not the name – but you get the idea!)

b. You also have to change the entry “Directory “C:/apache/htdocs/” to the same new directory: DocumentRoot “C:/localwebsites/siteXYZ/”

c. I copied the Apache index.html file from their htdocs directory into my “siteXYZ” directory, but you could use any index.html file you have to test the config file is setup correctly.

12. You can turn User Account Control back on if you want, via the control panel as before.

I have not addressed installing mySQL and PHP, but don’t want to clutter these instructions at this time.

Hope this helps!

Smitty

Tags: , , , , , ,

Leave a Reply