Getting Apache 2.2 to work with PHP 5.2 on Windows

Sad truth of the matter is that I need to be able to access Microsoft SQL from PHP.  The old cross-platform PHP mssql functions are depreciated and will not authenticate with SQL Server 2005 or 2008–now to access MSSQL stuff, you need to use Microsoft’s SQL Server 2005 Driver for PHP .  Which is only available for Windows.

I do all my primary development on a Mac, but now I have a Windows dev server for PHP apps that interface with Microsoft SQL.  This new machine runs Vista, and I’m using all the latest versions–(Apache 2.2 and PHP 5.2.6).

I’ve installed PHP on many Windows systems, and usually it is dead simple:

  • Install Apache
  • Download PHP, Zip Version
  • Unzip php zip file into c:\php
  • Copy php.ini-dist to php.ini
  • Modify the $PATH Environment Variables to include “c:\php”.  Reboot for changes to take effect
  • Append httpd.conf with
    LoadModule php5_module "c:/php/php5apache2.dll"
    AddType application/x-httpd-php .php
    PHPIniDir "C:/php"
  • Restart Apache

Only this time I was getting an error when I restarted Apache.  Checking the error.log I noticed this error.

Cannot load C:/php/php5apache2.dll into server: The specified module could not be found.

Strange error.  php5apache2.dll does exist and in that location.  I double and triple-checked.  It is there.

Eventually I discovered that if you’re using Apache 2.2 you need to use the php5apache2_2.dll not php5apache2.dll. This is not in PHP’s install.txt documentation, nor does the Apache error log steer you in the right direction.  It should say something like “unable to load module” not “module not found”.  You’re just supposed to know.  Nice.

So to recap, do everything the same except instead of putting this in your httpd.conf:

LoadModule php5_module "c:/php/php5apache2.dll"

use:

LoadModule php5_module "c:/php/php5apache2_2.dll"

So if you’re getting that error message, there is your solution.

Tags: , , , ,

Leave a Reply