PHP and Apache on Windows 7

Installing Apache webserver and PHP together on Windows 7 proved to be more cumbersome than it should be. I had seen this error many times when starting Apache.

“The requested operation has failed”

I went through many different versions of Apache and PHP until I hit the right combination, which I now going to document here.

Install PHP

This PHP is a manual installation.

php-5.2.17-Win32-VC6-x86.zip

copy the sample php.ini-recommended to php.ini

If necessary point to the ext directory (PHP defaults to the current directory unless you change it)

[code]

extension_dir=”C:\php\ext”

[/code]

I am not using an installer, so modifications will need to be made to the Apache config file (httpd.conf) so that Apache knows of PHP’s existence.

Install Apache

httpd-2.2.21-win32-x86-no_ssl.msi

and modify the contents with the following (of course ‘…’ is not part of the config file. just put the lines in the correct areas of the file.)

[code]

LoadModule php5_module “c:/php/php5apache2_2.dll”

<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir “C:/php”

[/code]

create a test page (phpinfo.php) and put it in the htdocs. If you see output, PHP is installed correctly!

[code]

<?php phpinfo(); ?>

[/code]

If all else fails run

httpd -e debug

from the console and view the output. It will usually tell you which module it is unable to load.

Leave a Reply

Your email address will not be published. Required fields are marked *