FastCGIExternalServer demystified

« 1 2 3 4 5 6 7 8 9View All»

Alias me

To make the thing fly work, we need to make one last modification to our virtual host configuration:

<VirtualHost *>
    ServerName    fcgi.test.local
    FastCGIExternalServer /fcgi/www/fcgi -host 127.0.0.1:9000
    AddHandler php-fastcgi .php
    Action php-fastcgi /virtualpath
    Alias /virtualpath /fcgi/www/fcgi
    DocumentRoot /srv/www/fcgi
    <Directory /srv/www/fcgi>
        AllowOverride   All
        Order           Allow,Deny
        Allow           from all
    </Directoy>
</VirtualHost>

The

Alias

directive instructs Apache to remap every call to /virtualpath to the new location /fcgi/www/fcgi and of course append all the stuff that was trailing the original path before. And alas, we now have a clean call to where our

FastCGIExternalServer

resides.

Recap:
To seperate our PHP code from the other stuff under the document root, we need to point the

FastCGIExternalServer

to some directory other than the original document root. To get to that very directory, we need to add a new Handler with

AddHandler

so Apache knows that files with the extension .php are to be treated specially. Next we have to create the

Action

we named as the handler for our PHP code. And finally we have to redirect the action to where our new FastCGIExternalServer thinks is his area of responsibility.

Do you spot the flaw?

Ok, that was easy: The (again, not so) virtual path for the

FastCGIExternalServer

doesn’t exist yet. So let’s fix that one, too:

mkdir -p /fcgi
cd /fcgi
ln -s /srv/www

This will provide a symbolic link to our document root. The only reason for having it really is the need to seperate our PHP code from all the other stuff. So essentially we came back full circle here just to make Apache and

FastCGIExternalServer

happy. Funny, isn’t it?

For must use cases, we’re finished here. However, there are some PHP apps out there that use deprecated internal variables and will refuse to work even after we fixed up almost everythin for them. To fix those remaining apps, too, we unfortunately need to modify either the app or PHP itself. So let’s deal with those, too.


Incoming search terms:

This entry was posted in PHP, Software, the ugly truth and tagged , , . Bookmark the permalink.

3 Responses to FastCGIExternalServer demystified

  1. Pingback: External FastCGI With Apache « IT Know-It-All

  2. Mattes says:

    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…

  3. Stefan Rubner says:

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>