How to enable Nginx to serve PHP code/pages in Ubuntu

mike mike503 at
Tue Nov 4 22:23:34 MSK 2008

don't use spawn-fcgi as i've had first hand problems with it not
behaving properly.

instead if you won't use php-fpm, just make a script that basically
does php-cgi -b $port (for TCP) - you can add in the environment
variables and sudo to make it run better - i wound up creating upstart
jobs in ubuntu (i think ~ 7.10 this is available)

this is my /etc/event.d/fastcgi-mike file:

start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5

stop on shutdown


exec /usr/bin/sudo -u mike /usr/local/bin/php-cgi -b 10500

this allows for:
- running as a different user id
- one file per pool
- auto startup on boot
- "stop fastcgi-mike" and "start fastcgi-mike" for stopping/starting
and it cleans it up properly
- proper environment variable support, as opposed to my experience
with spawn-fcgi ignoring PHP_FCGI_MAX_REQUESTS for example

php-fpm is the #1 option. #2 would be something like this (trigger it
how you like but this provides all the options one could want)

On Tue, Nov 4, 2008 at 6:22 AM, Edho P Arief <edho at> wrote:
> On Tue, Nov 4, 2008 at 8:42 PM, Roxis <roxis at> wrote:
>> On Tuesday 04 November 2008, Edho P Arief wrote:
>>> I'm also waiting for the day it's merged with PHP core but currently
>>> it's the one of the best way to spawn and manage php-fcgi processes,
>>> the other (not as good as using php-fpm) is using spawn-fcgi provided
>>> by lighttpd (explained here
>>> )
>> Wha's the big deal about spawn-fcgi?
>> Why is i better than an one-liner shell script?
> I don't know really, perhaps because it works on most system?
> --
> O< ascii ribbon campaign - stop html mail -

More information about the nginx mailing list