KDC Menu

Sunday, October 08, 2006

Installing PHP 5 with Apache 2.2 on Windows

You'll see in a previous blog that I got Apache 2 running with TomCat. Yesterday, I decided to intergrate PHP. Unfortunatley, I ran into pretty much the same issue as I ran into with associating TomCat with Apache: A DLL issue, which provides the error "The requested operation has failed" when attempting to start the Apache server.

The trick to getting PHP working with Apache is that there are multiple DLL files provided with the 5.2 release of PHP.

  • php5apache.dll
  • php5apache2.dll
  • php5apache2_2.dll

    The php5apache2_2.dll file is the DLL you want to use with Apache 2.2. Don't rename it, just point your httpd.conf file to it. You'll read in many places that these are the entries you need to add to your httpd.conf file:

    Put this line where you see a bunch of other LoadModule lines (leave the php5_module named just like this, even if you don't install PHP to a C:/php5 folder. The DLL file looks for the name.)
  • LoadModule php5_module "C:/php/php5apache2_2.dll

    Put this line in the block
  • ScriptAlias /php/ "C:/php/"

    Put this line in the block
  • AddType application/x-httpd-php .php .php3 .phps

    Then add index.php to your list of index files (files the server looks for if you don't specify a file, such as if you just go to http://localhost/

    DirectoryIndex index.html index.php


    Side Note: I opted not to take the CGI approach due to the warnings I've read on the vulnerability this approach opens to hackers.

    A great thread on this issue is located at:

    Free Workshop: How to Install PHP 5, Apache 2, MySQL 4.1, SQLite, SQLite Manager and XSLT on Windows

    My post to the thread was:
    Keith D Commiskey - kdcinfo.com: My problem with loading the "php5apache2_2.dll" file (php5 and apache 2.2) was because I'd installed it in C:/php, I changed the php5_module line to php_module (doh!). The dll specifically references php5_module.