Apache to the rescue!
Clearly we need a way to seperate the PHP code from all the other stuff in and below the document root. There’s a nice Apache config statement that allows us to du just that:
AddHandler
. So let’s modify our virtual host config a bit:
<VirtualHost *>
ServerName fcgi.test.local
FastCGIExternalServer /fcgi/www/fcgi -host 127.0.0.1:9000
AddHandler php-fastcgi .php
DocumentRoot /srv/www/fcgi
<Directory /srv/www/fcgi>
AllowOverride All
Order Allow,Deny
Allow from all
</Directoy>
</VirtualHost>
Now, what happened here? First, we changed the (not so virtual) path for the
FastCGHIExternalServer
to point to a new – as of yet non-existant – directory. Thus, the external PHP server will for the moment never be called and therefor it won’t interfere with graphics, CSS and other stuff.
Also, the new
AddHandler
directive instructs Apache to call the Action named
php-fastcgi
for every file with an extenstion of
.php
. So obviously we have to provide this handler using the
Action
directive.

Pingback: External FastCGI With Apache « IT Know-It-All
Great article, but how did you solve the problem with the trailing index.php?
If I call the domain, the php file are provided as a download.
If I add index.php, I get redirected to /virtualpath/index.php/ which results in a 404. Everything else works like a charm…
Can’t really say what the problem with your setup is. Either it’s a missing “DirectoryIndex index.php” statement in the htpd.conf file or your settings for calling the FCGI process are a bit borked. If you could post the settings for your vhost, maybe I could help more then.