FastCGIExternalServer demystified

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


First we need to create our example page:

mkdir -p /srv/www/fcgi
echo "<?php phpinfo(); ?>" > /srv/www/fcgi/index.php

Also it helps to start our PHP FastCGI server:

export PHP_FCGI_CHILDREN=64
export PHP_FCGI_MAX_REQUESTS=2345
/opt/php-fcgi/bin/php-cgi -b :9000 &

What we’re doing here is to tell PHP that it’s got to start 64 independent servers waiting to serve requests. After having served 2345 requests any of these servers will quit and restart to prevent our server machine from dying of memory leaks still being caused by PHP.

As a last step, we need to tell our client machine where to find the server “fcgi.test.local”. This is done by adding a line to the file

/etc/hosts

if you’re on Linux or Mac OS or to

C:\Windoze\System32\drivers\etc\hosts

if you’re on a less desireable OS:

192.168.1.100    fcgi.test.local

Make sure to replace the 192.168.1.100 with the actual IP address of the web server you use for testing.


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>