Sunday, January 6, 2008

Install Apache 2.2 with PHP 5 on Windows Vista

Hello

I spent some hours installing Apache-PHP on Windows vista, and I think it will be helpful to publish the detail instructions.

Suggestion: It is always a good practice, especially if you are a beginner, to make a backup of the configuration files. For example you can follow the pattern: filename-YYDDMMhhmm.ext

Installing Apache HTTP Server (2.2.6)
  1. Download Apache 2 binaries for windows and save it in the desktop - for example. This version has fixed the problems with the Apache Monitor.

  2. If you have any web server, like IIS, or other application using the port 80, stop it before start the installation. Type the following at the prompt for find out if the port 80 is already taken (look for the pattern '%s':80 in the second column), c:\> netstat -ao find /i "listening"

  3. Open the command window with administrator privileges. Go to start > All programs > Accessories. Right-click on Command Prompt and select run as administrator. Note: It is not necessary to stop the User Account Control (UAC).

  4. Run the setup from the command window just opened. Browse to the directory where you save apache, c:\users\user-name\desktop in this case, and type in the command prompt, c:\users\user-name\desktop> msiexec /i apache_2.2.6-win32-x86-no_ssl.msi

  5. Install Apache in its default location, C:\Program Files\Apache Software Foundation\Apache2.2 , or choose one appropriate for you.

  6. When the wizard ask you for the domain, server name, and administrator email write the appropriate values if you are installing a production server, otherwise write the values suggested between parenthesis ().

  7. Choose the default server on port 80 for all users option.

  8. When the install finishes you can try http://localhost/ in the web browser and it should show you "It works". :)

  9. For stop, start, and restart Apache HTTP Server, go to Start > All programs > Apache HTTP Server 2.2.6 > Control Apache Server, and right-click on the desire option and select run as administrator.

  10. Troubleshooting: The log file of install and general errors is located on the folder C:\Program Files\Apache Software Foundation\Apache2.2\logs. You can also use the option on Start > All programs > Apache HTTP Server 2.26 > Configure Apache Server > Test configuration to see if there is any error on the configuration file of Apache, httpd.conf.

Installing PHP (5.2.5)
  1. Download the windows binaries zip package of php. I tried to use the installer, but I got an error configuring PHP with CGI as well as with module; something like "...Parent: Received restart signal -- Restarting the server....Child 8448: Exit event signaled. Child process is ending" in the error.log file. So we proceed with a manual installation. Anyway, manual installation is always recommended because there is more things to learn :).

  2. Unzipped the files in c:\php. A location without spaces is preferred. (You could read the install.txt file for further information about it).

  3. Copy the file php.ini-recommended to a new file named php.ini

  4. Go to start and right-click on computer and click on properties. In the new opened window, click on Advanced system settings, on the left panel, and the System properties window will be opened. Select the tab advanced, and click on Environment variables button. In the system variables panel, look for the Path variable and click in the Edit button. Add at the end of the Path environment variable, the path were PHP is installed, ...;C:\php\ . This indicates the path of the file php5ts.dll, the main dll of PHP.

  5. Open the notepad or your favorite text editor with administrator privileges and open the httpd.conf located in C:\Program Files\Apache Software Foundation\Apache2.2\conf. Append the following lines to the file httpd.conf at the end, to configure PHP as a module.
    PHPIniDir "C:/php/"
    LoadModule php5_module "c:/php/php5apache2_2.dll"
    AddType application/x-httpd-php .php

  6. Restart apache. Go to Start > All programs > Apache HTTP Server 2.2.6 > Control Apache Server, and right-click on the restart option and select run as administrator.

  7. Do the following for test the Apache-PHP integration. Create a file called test.php in the folder C:\Program Files\Apache Software Foundation\Apache2.2\htdocs with he content: <?php phpinfo(); ?>

  8. Open the web browser and go to http://localhost/test.php. You should see general information about the current state of the PHP installed.

Next, I will publish general additional settings that I commonly use to personalize the developing environment.

Good luck

Mr. Anderson

10 comments:

Tucker said...

Thanks a lot for this detailed and working (!) description.
One hint for a full working WAMP stack: current MySQl-Release 5.0.51a has a Vista bug: http://bugs.mysql.com/bug.php?id=34340

Unknown said...

It didn't work. phpinfo() test.php comes up blank.

thanks anyway!

Alberto Borda said...

Thank you psycho... I did not notice blooger delete the < and > content ...
If you still have a problem, I suggest you review the configuration of httpd.conf and restart apache after that.

Unknown said...

Hello:

I have been struggling mightily with this install. Your instructions were clear and easy to follow for a newbie.

It worked the first time.

Thank you very much.

... Linus ... said...

Hey!
Thanks a ton.. I spent about 5 hrs to configure php and apache, nothing worked but this!

keep it going!
SS

e-v-e rything said...

hi there...
ive been doing research on installing apache on my vista with php5 for a couple of hours, to no avail.

until i found this...thank you so much... im a newbie here and all instructions are pretty simple and very clear.

more power to mr.anderson

cyberfrog said...

Hi,

I have been struggling for some hours now to get both php and apache talking, and even though your instructions are clear for some reaqson when I try to launch my tets.php, it opens dreamweaver and gives me a blank page? I am assuming dreamweaver isn't the problem here........

Would appreciate any advice

Cheers

Unknown said...

Thanks for the simple instructions, it worked great. I was using php5apache2.dll module and it says it wasn't found, I didn't realize there is another one for 2.2 as follow: php5apache2_2.dll

Unknown said...

Mr. Anderson.
Port 80 is taken, you mention that i should stop the process that is controlling port 80. I am a novice at this and am learning PHP. How do I stop a process? and How do I find out what that process is?

txs
The Dude

Topcat said...

Thank you so much. After cleaning up my original effort, this worked beautifully.