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.