Ever since PHP stopped working with the official builds of Apache, I had to use an unofficial build. Since then, I've had problems, though I can't figure out whether they're the fault of the unofficial build or PHP. The big problem is that Internet Explorer seems to cause Apache to stop responding to requests after a while. It'll work without problems if requests come from any other browser. I know that lighttpd works just fine on my Linux machine with PHP (FastCGI), so I tried looking at that for my Windows development machine. Unfortunately, the only way I could get it to work properly was with CGI, which is kind of slow compared to the always-running Apache module. That pretty much wipes out the benefit of switching to a light web server like lighttpd. While looking at the PHP documentation (some of which is pretty dated), I found that Apache can run PHP using FastCGI. I figured I'd give it a try. Using the comments and my knowledge of the changes to the Apache configuration file format for Apache 2.4, I set Apache to use FastCGI instead of the PHP Apache 2.4 module by using mod_fcgid. The appropriate changes look something like this:
Require all granted
FcgidInitialEnv PHPRC "C:/PROGRA~2/PHP" # Tell PHP where php.ini is
AddHandler fcgid-script .php
FcgidWrapper "C:/PROGRA~2/PHP/php-cgi.exe" .php # Can't have spaces in the path
Notice the "PROGRA~2" path. The FastCGI module doesn't like spaces in paths. Also, the PHP path needs to have some permissive access or it won't bother loading PHP. The document root needs to have "ExecCGI" in the "Options" directive or PHP scripts will return a 403 error. Once I got that squared away, I loaded a page with
phpinfo();. "CGI/FastCGI" showed up in the Server API and php-cgi.exe showed up in my running processes. I ran some other more complex scripts and those ran just fine.
Since everything worked, I decided to try accessing my pages from Internet Explorer to see if that solved the problem. Unfortunately, it didn't. I eventually found the problem as I messed with the Apache configuration. I needed a line like this in my file:
AcceptFilter http none
AcceptFilter https none # If you use HTTPS, you need this one
According to the documentation, you only need to specify a non-default AcceptFilter for broken network drivers or virtual network providers. The weird thing is this problem only affected Internet Explorer and didn't affect Firefox, Mobile Safari, Chromium, Epiphany/Web, or Konqueror (all the browsers I have access to other than IE). I'd imagine that just means Internet Explorer does something with its connections that all the other browsers don't.