I have come across a handful of different methods detailed on the
Internet for getting PHP running with nginx, but haven’t come across the
‘definitive’ version. What method do the regular nginx users on here
favour?
On Fri, Nov 13, 2009 at 13:45, John M. [email protected] wrote:
I have come across a handful of different methods detailed on the Internet
for getting PHP running with nginx, but haven’t come across the ‘definitive’
version. What method do the regular nginx users on here favour?
Did you search? You’ll need a FastCGI daemon or you can proxy it to
apache’s mod_php or something else. There’s no definite method, so
it’s your pick. On Debian the php-cgi package serves me just fine.
HTH
Nuno Magalhães wrote:
Yes, I searched - the fact that I said “I have come across a handful of
different methods detailed on the Internet for getting PHP running with
nginx” surely indicates that. In fact, I’ve been running a PHP/nginx
combination for some time, using the technique outlined here:
http://jit.nuance9.com/2008/01/serving-php5-with-nginx-on-ubuntu-710.html
It works fine, although I’ve not tested it under load. But I came across
this posting, which suggested a more efficient way to do it:
http://tomasz.sterna.tv/2009/04/php-fastcgi-with-nginx-on-ubuntu/
He says “There are dozens of HOWTOs for configuring nginx to direct .php
files requests to FastCGI, but only a few covering the topic of running
the PHP FastCGI backend. None of them covers the correct way, though.
Let me show you how to get it right…PHP CGI binary is perfectly able
running a FastCGI interface by itself. There is no need to run it with
an external wrapper. No need to install anything more than the PHP
itself.”
When I tried a while back, I couldn’t get this working, I can’t exactly
recall why, but I was planning on giving it another go unless I came
across another technique which I knew was widely adopted with success,
hence my question.
I suppose I should really have named the topic “Best way to use PHP with
nginx under Ubuntu” because that’s what I’m most interested in.
Nuno Magalhães wrote:
Yes, I searched. In fact, I’ve been running a PHP/nginx combination for
some time, using the technique outlined here:
http://jit.nuance9.com/2008/01/serving-php5-with-nginx-on-ubuntu-710.html
It works fine, although I’ve not tested it under load. But I came across
this posting, which suggested a more efficient way to do it:
http://tomasz.sterna.tv/2009/04/php-fastcgi-with-nginx-on-ubuntu/
He says “There are dozens of HOWTOs for configuring nginx to direct .php
files requests to FastCGI, but only a few covering the topic of running
the PHP FastCGI backend. None of them covers the correct way, though.
Let me show you how to get it right…PHP CGI binary is perfectly able
running a FastCGI interface by itself. There is no need to run it with
an external wrapper. No need to install anything more than the PHP
itself.”
When I tried a while back, I couldn’t get this working, I can’t exactly
recall why, but I was planning on giving it another go unless I came
across another technique which I knew was widely adopted with success,
hence my question.
I suppose I should really have named the topic “Best way to use PHP with
nginx under Ubuntu” because that’s what I’m most interested in.
Hi,
Is there a php-fastcgi process launcher and controller at the same time
?
Because php-fastcgi or spwan-fcgi just launches N php children, N
constant.
I’m looking for a way to spawn fastcgi process depending on the number
of concurent requests … has anyone heard about something like that ?
++ jerome
2009/11/13 Nuno Magalhães [email protected]:
2009/11/13 Jérôme Loyet [email protected]:
Hi,
Is there a php-fastcgi process launcher and controller at the same time ?
Because php-fastcgi or spwan-fcgi just launches N php children, N constant.
I’m looking for a way to spawn fastcgi process depending on the number
of concurent requests … has anyone heard about something like that ?
Those are scripts, i think you can adapt them replacing N with $N, and
evoking the script with whichever number you need. And a similar
script to kill processes as well.
On Fri, Nov 13, 2009 at 14:43, John M. [email protected] wrote:
[…]
He says “There are dozens of HOWTOs for configuring nginx to direct .php
files requests to FastCGI, but only a few covering the topic of running the
PHP FastCGI backend. None of them covers the correct way, though. Let me
show you how to get it right…PHP CGI binary is perfectly able running a
FastCGI interface by itself. There is no need to run it with an external
wrapper. No need to install anything more than the PHP itself.”
[…]
I suppose I should really have named the topic “Best way to use PHP with
nginx under Ubuntu” because that’s what I’m most interested in.
PHP does come as CLI and/or CGI. Ubuntu is Debian-based, so you’ll
most likely just need the php-cgi package (or similar) and a boot
script to start it up, which will probably be included and placed
under /etc/init.d
2009/11/13 Jérôme Loyet [email protected]:
Is there a php-fastcgi process launcher and controller at the same time ?
Because php-fastcgi or spwan-fcgi just launches N php children, N constant.
I’m looking for a way to spawn fastcgi process depending on the number
of concurent requests … has anyone heard about something like that ?
Try PHP FPM
http://php-fpm.org/
On 13.11.2009, at 16:45, John M. wrote:
I have come across a handful of different methods detailed on the
Internet for getting PHP running with nginx, but haven’t come across
the ‘definitive’ version. What method do the regular nginx users on
here favour?
This thread might be of help:
It’s about complicated things (unstable nginx module, process
supervising), so get ready
On Fri, Nov 13, 2009 at 07:03:07PM +0300, Peter L. wrote:
It’s about complicated things (unstable nginx module, process
supervising), so get ready
Just in case you missed it, the module is already available:
Oh, and we never said it’s unstable, it’s just young and not yet tested
enough to be considered bulletproof.
OTOH, it might be a tad overkill for simple PHP serving, you may wish to
use php-fpm instead.
Best regards,
Grzegorz N.
Peter L. wrote:
Re: Launch FastCGI process?
It’s about complicated things (unstable nginx module, process
supervising), so get ready
I have an aversion to complicated things :). Actually, I gave the Tomasz
Sterna method a go on a new Ubuntu installation and it worked perfectly,
and is seemingly rather simpler than the previous method I’ve tried. I’m
just wondering why it’s not universally adopted. What is the value of
spawn-fcgi, which Igor S. give the thumbs-up to in the thread you
mention?
John
2009/11/13 John M. [email protected]:
This thread might be of help:
Re: Launch FastCGI process?
It’s about complicated things (unstable nginx module, process
supervising), so get readyI have an aversion to complicated things :). Actually, I gave the Tomasz
Sterna method a go on a new Ubuntu installation and it worked perfectly, and
is seemingly rather simpler than the previous method I’ve tried. I’m just
wondering why it’s not universally adopted. What is the value of spawn-fcgi,
which Igor S. give the thumbs-up to in the thread you mention?
spawn-fcgi is almost the same thing, it’s just a generic launcher for
fastcgi processes with features like chroot or change owner. At the
end, there is no spawn-fastcgi process running, as I said it’s just a
launcher.
So spawn-fcgi and php-fastcgi are “kif kif” (“the same” in french) or
in a shorter way : “the same shit” (not scalable, no fine management,
no real chroot, …)
php-fpm is interesting but it has patch PHP to work, when a fully PHP
supported version ?
Jérôme Loyet wrote:
Re: Launch FastCGI process?
spawn-fcgi is almost the same thing, it’s just a generic launcher for
fastcgi processes with features like chroot or change owner. At the
end, there is no spawn-fastcgi process running, as I said it’s just a
launcher.So spawn-fcgi and php-fastcgi are “kif kif” (“the same” in french) or
in a shorter way : “the same shit” (not scalable, no fine management,
no real chroot, …)php-fpm is interesting but it has patch PHP to work, when a fully PHP
supported version ?
php-fpm actually uses PHP’s sources to build its own binary. AFAIK it
doesn’t change anything in PHP itself.
You launch the daemon this way:
/usr/local/bin/php-fpm --fpm-config /usr/local/etc/php-fpm/php-fpm.conf
Work is being done to integrate the project on the main PHP tree.
Regards
Ðа петък 13 ноември 2009 16:28:57 Jérôme Loyet напиÑа:
Hi,
Is there a php-fastcgi process launcher and controller at the same time ?
Because php-fastcgi or spwan-fcgi just launches N php children, N constant.
I’m looking for a way to spawn fastcgi process depending on the number
of concurent requests … has anyone heard about something like that ?
The simplest approach would be to just hack the php code that starts N
children processes and somehow control that N, here is an example [1].
There
is a more complicated approach, that of php-fpm, it can do a lot more
than
just launch N processes. What it still cannot do (as of my knowledge,
but that
might have changed) is to dynamically control that N number. If you give
them
some money, maybe they will fix that part soon.
1: http://xaxo.eu/en/patches_php-ctrlfifo.html
Momchil
On 13.11.2009, at 19:27, Grzegorz N. [email protected]
wrote:
On Fri, Nov 13, 2009 at 07:03:07PM +0300, Peter L. wrote:
This thread might be of help: Re: Launch FastCGI process?
It’s about complicated things (unstable nginx module, process
supervising), so get readyJust in case you missed it, the module is already available:
FRiCKLE Labs & MegiTeam pres. ngx_supervisord
Took a note.
Oh, and we never said it’s unstable, it’s just young and not yet
tested
enough to be considered bulletproof.
Oh, I’m sorry, misunderstood you.
OTOH, it might be a tad overkill for simple PHP serving, you may
wish to
use php-fpm instead.
IMHO, an idea of this module is more than awesome, so I was unable to
hold myself from a notice
2009/11/15 Momchil I. [email protected]:
is a more complicated approach, that of php-fpm, it can do a lot more than
just launch N processes. What it still cannot do (as of my knowledge, but that
might have changed) is to dynamically control that N number. If you give them
some money, maybe they will fix that part soon.
There is several software or patches which can handle this kind of
stuff, but none is stable, none is suitable
php-fpm looks great, but it’s not accurate enought because it’s:
a patch to php core, it depends on a certain version of libevent (and
it’s not compatible with OpenBSD for example), it’s still a beta, some
features are missing … it’s a good start but definitely not enought.
On 13-11-2009, John M. wrote:
I have come across a handful of different methods detailed on the
Internet for getting PHP running with nginx, but haven’t come across the
‘definitive’ version. What method do the regular nginx users on here favour?
I used spawn-fcgi, but with this thread i tried php-cgi -b, it’s more
simple to install on debian.
I use supervisord to start it, autostart=unexepected since v 3 (the
sample.conf is not correct, it says =true), and i just saw that when
php-cgi stop it exit with error 0 so it was not restarted !
Sorry for my bad english. I just mean that if you use supervisord with
php-cgi -b you should set autorestart=true
bye
On pią, lis 13, 2009 at 04:28:57 +0100, Jérôme Loyet wrote:
Hi,
Is there a php-fastcgi process launcher and controller at the same time ?
Because php-fastcgi or spwan-fcgi just launches N php children, N constant.
I’m looking for a way to spawn fastcgi process depending on the number
of concurent requests … has anyone heard about something like that ?
nginx, supervisord and ngx_supervisord, though it complicates a typical
PHP setup a little (also, see elsethread for a configuration gotcha
about autorestarting PHP).
I actually have written support for dynamic php pool size at one time
but I cannot publish it, sorry.
Best regards,
Grzegorz N.
Le 15 novembre 2009 15:48, Jérôme Loyet [email protected] a écrit :
children processes and somehow control that N, here is an example [1]. There
php-fpm looks great, but it’s not accurate enought because it’s:
a patch to php core, it depends on a certain version of libevent (and
it’s not compatible with OpenBSD for example), it’s still a beta, some
features are missing … it’s a good start but definitely not enought.
I forgot that php-fpm uses xml as a configuration file which is lame
and not php conf file compliant