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.


    Keith D Commiskey
    https://keithdc.com
  • 3 thoughts on “Installing PHP 5 with Apache 2.2 on Windows

    1. I found while installing Apache 2.2.3/PHP 5.2.0 on another computer, although it was still a Windows box, that I had to change the forward slashes to backslashes in the httpd.conf file.

      Change:
      PHPINIDir C:/php
      LoadModule php5_module “C:/php/php5apache2_2.dll”

      To:
      PHPINIDir C:php
      LoadModule php5_module “C:phpphp5apache2_2.dll”

    2. I was curuous if you eber considered changing the page layout oof your blog?

      Its very well written; I love what youve got too say.

      But maybe you could a little more in the way of content so people could connect with
      it better. Youve got an awful lot of text for onky having
      one or 2 images. Maybe yoou could space it out better?

    3. Based on your input, I changed my blog's layout to a responsive design provided by blogger.com (I've never got around to looking for more modern blogging sites.)

      I also added a few screenshots, and will bear this in mind for future blog posts. You are correct in that images not only help break the monotony of a wall of text, but can add to the understanding through its association with the subject matter.

      Thank you for your input.

    Leave a Reply