Dmitry Leskov

Apache 2.2 cannot load php5apache2_2.dll – Problem Solved

It was a pleasant surprise for me to learn that File Information functions are enabled by default as of PHP 5.3.0. No need to figure out PECL and PEAR, set up the environment to compile from source, or beg for a Windows binary in PHP developer forums, thought I. Upgrading from 5.2.6 would be as easy as making the respective lines in Apache’s httpd.conf point to the 5.3.0 installation…

I was wrong. Apache won’t start and it took me more than half an hour to figure out what’s going on.

First, PHP for Windows comes in several binary incarnations. The official site suggests that “VC6″ PHP binaries must be used with Apache binaries, whereas e.g. this SitePoint article states that “VC9″ PHP binaries must be used with Apache binaries provided by ApacheLounge. As far as I could recall, I had the binaries, so I tried the VC6 build and Apache crashed on startup with access violation. Assuming a memory failure on my part, I tried the VC9 build but Apache still won’t start, this time with the following event appearing in the Event Log:

Event Type:	Error
Event Source:	Apache Service
Event Category:	None
Event ID:	3299
 .  .  .
The Apache service named  reported the following error:
>>> httpd.exe: Syntax error on line 490 of O:/apache-2.2/conf/httpd.conf: 
Cannot load O:/php-5.3.0/php5apache2_2.dll into server: The specified 
procedure could not be found.

So I searched for “Apache 2.2 cannot load php5apache2_2.dll” and spent the next twenty or so minutes reading various forums and blog posts, to no avail.

When nothing helps, read the manual. I have re-read the “Apache 2.0.x on Microsoft Windows” section in the PHP install.txt file and noticed:

Note: You should read the manual installation steps first!

This made me think: “Hmm. Perhaps I had done something when installing PHP 5.2.6?” I scrolled to “Manual Installation Steps” and you know what, it turned out to be the case!

The CGI and CLI binaries, and the web server modules all require the
php5ts.dll file to be available to them. 
   .  .  .
To make php5ts.dll available you have three options: copy
the file to the Windows system directory, copy the file to the web
server's directory, or add your PHP directory, C:\php to the PATH.

I blindly trust Windows Update to mess with my Windows system directory, but never manually copy files there, so the first option was ruled out. PHP was not in the PATH either, so looked into Apache bin/ directory and voila, php5ts.dll was right there.

However, replacing it with php5ts.dll from PHP 5.3.0 did not help. Fortunately, at this point I recalled switching to the VC9 build in an attempt to solve the access violation problem. Switched back to VC6 and Apache finally starts!

Lessons learned:

  • Manual installation now means manual uninstallation/upgrade in the future. Take notes during the process.
  • When you have to resort to reading the manual – read, don’t scan

Tags: , ,

| »


  1. 1

    [...] also read this blog where some VC6 and VC9 binaries are mentioned. I don’t know about them. Do I need to do [...]