Bear Flag Republic Radio Weblog

Living out on the left coast

Last modified:
4/1/05; 10:07:32 AM

Feeds:

LIVE webcam Cumbres & Toltec rail yard in Chama, New Mexico.

Current BlogRoll.

Click here to send an email to the editor of this weblog.

Click to see the XML version of this web page.

Click here to visit the Radio UserLand website.

 Tuesday, March 8, 2005
Trade Secret #1.

Because I’ve gotten about the 124th request today as to how I do Suexec’ed PHP-FastCGI under Apache2 (ala Zeus—but it works), I thought I would go ahead and share.

There’s nothing particularly special about it, it’s one of the methods in PHP’s FastCGI.README (the dynamic one, you can also externally spawn PHP with php -b and have it listen as a port).

You’ll want to have Apache2 installed, the FastCGI developer kit and mod_fastcgi.

Then you’ll compile PHP with FastCGI support, and copy that binary to somewhere like /usr/local/www/php5-fcgi. Within the PHP directory where you just ran make, you’ll

cp sapi/cgi/php /usr/local/www/cgi-bin/php5-fcgi

And then you’ll see cgi-fcgi in your version

> /usr/local/www/cgi-bin/php5-fcgi -v
PHP 5.0.3 (cgi-fcgi) (built: Dec 30 2004 22:44:32)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
with eAccelerator v0.9.2, Copyright (c) 2004-2004 eAccelerator,by eAccelerator
with Zend Extension Manager v1.0.6, Copyright (c) 2003-2004, by Zend Technologies
with Zend Optimizer v2.5.7, Copyright (c) 1998-2004, by Zend Technologies

Now to tie this into Apache2 and suexec it by putting the following in

SuexecUserGroup ${USER} ${GROUP}
ScriptAlias /php-fastcgi/ ${HOME}/php-fastcgi/ 
AddType application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /php-fastcgi/php5-fcgi 

What this does is call up a text-based wrapper (a file literally called php5-fcgi) in a person’s home directory, this is required for the suexecing to really work:

> cat ${HOME}/php-fastcgi/php5-fcgi
	

#!/bin/sh PHPRC="/usr/local/etc" export PHPRC PHP_FCGI_CHILDREN=8 export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=5000 export PHP_FCGI_MAX_REQUESTS exec /usr/local/www/cgi-bin/php5-fcgi

Now at this point you’re at least at suexec’ed PHP-CGI and you can set the PHPRC variable to be the directory that is scanned for a php.ini file. The nice thing about using AddType is that you can still have mod_php centrally installed with

AddType application/x-httpd-php .php

and this will be the fallback to any virtualhost that doesn’t have the php-fcgi for .php in it. You can also see that you can control it extension-by-extension and location-by-location by differentially using both of these.

In order to FastCGI your PHP, you need to config FastCGI in httpd.confg


FastCgiIpcDir /usr/local/www/fcgi_ipc/tmp
AddHandler fastcgi-script .fcgi
FastCgiSuexec /usr/local/sbin/suexec
FastCgiConfig -singleThreshold 100 -killInterval 300 -autoUpdate -idle-timeout 240 -pass-header HTTP_AUTHORIZATION

And finally tell mod_fastcgi to execute anything the in the php-fastcgi location as fastcgi.


Options ExecCGI        
SetHandler fastcgi-script

With this active, your suexec’ed PHP will be FastCGI and with it commented out, it will be straight PHP-CGI.

Have Fun! And now go off and start yourself a web hosting company.

[TextDrive Weblog]
comments < 7:58:14 PM        >

Powerbook Motion Sensor Used For More Than Saving HDs [MacSlash]
comments < 7:51:07 PM        >


Archive:

March 2005
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Feb   Apr


Links:
428 CobraJet Registry
ARRL
ARRL Contest Branch
Book Pool
Chama NM Web Cam
Cumbres&Toltec Scenic RR
Dilbert
Digital Photography Review
eHam Radio on the Net
Home Power Magazine
Internet Radio Linking Project
John Robb
Mini Usa
Motoring File
NASA Human SpaceFlight
Open Secrets
Palo Alto Amateur Radio Association
Radio Amateur Satellite Corporation
Railroad News
Scripting News
SF Giants
South County Amateur Radio Emergency Service
Southern Pacific Historical and Technical Society
Space Weather
The Factory - Go back to 1965, the Shelby Mustang Factory, where on a quite night you can here Chevy RUSTING!
The Shifted Librarian
Through the Looking Glass
Tom's Hardware
William Shatner

Click to see the XML version of this web page.  Click here to send an email to the editor of this weblog.
Last Update: 4/1/05; 10:07:32 AM Copyright 2005 Steve Brune, All Rights Reserved.
Click here to visit the Radio UserLand website. Subscribe to "Bear Flag Republic Radio Weblog" in Radio UserLand.