Installing Apache and php on Vista

Yet another article explaining how to install php and Apache on Vista?

You bet!

After spending way too much time getting this done for myself and finding many incomplete solutions in the top Google picks I hope to help others with something that should not even need an explanation.

I hardly ever boot Vista but for work I was forced to setup up an Apache, php, MySQL development environment on my Vista partition. Please note: Do not follow these instructions if you are setting up a productive environment.

The first (wrong) assumption was that I download the programs and install one after the other and everything just works. First of I was not certain what to enter into the installations masks. After installing Apache I got an error along the line of:

make_sock could not bind to address 0.0.0.0:80

or

Could not reliably determine the server’s fully qualified domain name

All of the files of the php and Apache installation were not writeable. After finally getting Apache to run, I just could not figure out how to install php with many different installation instructions adding to the confusion.

While I am not sure if all of these steps are necessary, this is how it worked for me, your mileage may of course vary:

  1. Download apache (my version 2.2.11) msi file
  2. Turn off UAC (user account control) I know nothing about Vista UAC and the  implications of turning it off. Please do this at your own risk.
  3. To turn off UAC: Start-> Control Panel -> User Accounts -> User Accounts -> Turn User Account Control on or off
  4. Uncheck “Use User Account Control (UAC) to help protect your computer” -> OK
  5. Reboot
  6. Start -> All Programs -> Accessories -> Command Prompt -> Right Click -> Run as Administrator
  7. Run: ”msiexec /i C:\Users\yourusername\Documents\Downloads\apache_2.2.11-win32-x86-openssl-0.9.8i.msi” (your apache .msi file may be named differently and your download directory may be different)
  8. Enter the following (unless you know better): Network Domain = localhost, Server Name = localhost, admin email = your@email
  9. Installation directory, choose C:\Apache instead of C:\Program Files\bla bla bla\. One of the reasons is as I have been told, that the Program Files directory gives you all sorts of problems when you want to read and write your files. In my failed attempts to install php and apache, php installation was not able to write to httpd.conf and could not install, failed apache installation could not write log files and I could not update index.html.
  10. I still got a bunch of error messages after installation and could not start Apache via the Apache Service Monitor, so reboot to the rescue. After that I could start apache.

Now that Apache was installed it was time to install php:

  1. Downlaod php (my version 5.2.9) msi file
  2. Make sure UAC is still turned off (see apache installation above)
  3. Start -> All Programs -> Accessories -> Command Prompt -> Right Click -> Run as Administrator
  4. Run: ”msiexec /i C:\Users\yourusername\Documents\Downloads\php-5.2.9-win32-installer.msi” (your php .msi file may be named differently and your download directory may be different)
  5. Web Server Setup -> Choose your webserver, in my case Apache 2.2.x Module
  6. Apache Configuration Directory, in my case “C:\Apache\conf\”. In any case it is the conf directory of your apache installation.
  7. Extensions to install, in my case MySQL
  8. Installation directory, I chose C:\PHP instead of the suggested “Program Files” dir for reasons mentioned above.
  9. Strange enough, you still need to make some modifications to apache’s conf/httpd.conf file, so open it with a text editor like vim or jEdit.
  10. You will find the following lines at the end of the file:  PHPIniDir “C:/PHP/” and LoadModule php5_module “C:/PHP/php5apache2_2.dll”
  11. What is missing are the lines “AddType application/x-httpd-php .php” and “AddType application/x-httpd-php-source .phps” in the section “<IfModule mime_module>”. For example just add these lines after the entry for x-gzip. Make sure you do not have any unnecessary spaches in the mime type like I saw in one of the tutorials I googled.
  12. Reboot your machine, apache should be running.
  13. Create a file test.php in htdocs with something like <?php phpinfo(); ?> and navigate to http://localhost/test.php and you should see your php output.

I sincerely hope that I was able to help somebody save some time by giving a few pointers. Of course there are many more things that can and must be configured to get the setup just right for your purposes but the basic installation should now be working.

If you have the choice of your underlying operating system why not try to setup Apache and php on OpenSolaris or Linux? You will find installation easy by using the build in package manager, no hassle with UAC, no need for additional configuration, no non-writeable directories, no need for reboots. It is a simple, straightforward process that works out of the box.

Tags: , , , , ,

Leave a Reply