Php-fastcgi always exits resulting in 502 bad gateway

Hello everyone,

I’m using nginx since some days and I got a little trouble. It seems
that after some while of working fine nginx exits the fastcgi-daemon and
whenever I try to call a php site then, it shows me 502 Bad Gateway.

Then I have to “/usr/bin/php-fastcgi start” and everything runs fine
again.

So basically my question: How do I make the php-fastcgi not exit itself
or how do I make it automatically restart on exit? It’s annoying that my
website everytime turns to “502 Bad Gateway” to everyone and I don’t
even know about that!

Can anyone help me please? :frowning:

Posted at Nginx Forum:

So basically my question: How do I make the php-fastcgi not exit itself or how
do I make it automatically restart on exit?

Best way to do it is to use inbuilt process manager PHP-FPM
PHP: FastCGI Process Manager (FPM) - Manual (since 5.3.x its in php
core).

rr

I’m running Debian Lenny which has only php 5.2 :frowning:

I tried apt-get install php5-fpm and php-fpm, but both don’t work. How
to get it on Debian Lenny? I cant compile php on my own… :frowning:

Posted at Nginx Forum:

On Sep 22, 2011 6:44 PM, “Lintu” [email protected] wrote:

I’m running Debian Lenny which has only php 5.2 :frowning:

I tried apt-get install php5-fpm and php-fpm, but both don’t work. How
to get it on Debian Lenny? I cant compile php on my own…

Install supervisord. You can then create as many php-cgi processes using
supervisord which will be automatically restarted upon killed.

I usually use virtualenv to create dedicated python environment for
supervisord.

  • extract virtualenv to /opt
  • create supervisord environment by issuing
    /opt/virtualenv/virtualenv.py /opt/supervisor
  • install supervisord
    /opt/supervisor/bin/easy_install supervisor
  • configure accordingly (check its documentation)

Hey, thanks for the tip with supervisord.

I found a site
(Using supervisord for Nginx+FastCGI+PHP :: Sacha Chua)
saying its easy to set up with:

apt-get install python-setuptools
easy_install supervisor

And actually it was. No error on that. But then the site says I should
add something to /etc/supervisord.conf, but there is no file like that?
I created it with the content I got told to, but well, nothing happens
now… Or is everything fine now? Is everything automated about
supervisord?

Posted at Nginx Forum:

From: Lintu [email protected]

I’m using nginx since some days and I got a little trouble. It seems
that after some while of working fine nginx exits the fastcgi-daemon and
whenever I try to call a php site then, it shows me 502 Bad Gateway.
Then I have to “/usr/bin/php-fastcgi start” and everything runs fine
again.
So basically my question: How do I make the php-fastcgi not exit itself
or how do I make it automatically restart on exit? It’s annoying that my
website everytime turns to “502 Bad Gateway” to everyone and I
don’t even know about that!

We use spawn-fcgi here.

JD

On Thu, Sep 22, 2011 at 7:08 PM, Lintu [email protected] wrote:

add something to /etc/supervisord.conf, but there is no file like that?
I created it with the content I got told to, but well, nothing happens
now… Or is everything fine now? Is everything automated about
supervisord?

run supervisorctl or just use ps check if the php-cgi processes are
running. Set nginx fastcgi_pass to whatever path you set in
supervisord for php-cgi.


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Thu, Sep 22, 2011 at 7:22 PM, Edho P Arief [email protected] wrote:

And actually it was. No error on that. But then the site says I should
add something to /etc/supervisord.conf, but there is no file like that?

the basic config can be generated by command echo_supervisord_conf
(you need to copy-paste the result or pipe it to file).


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On 22 Set 2011 11h44 WEST, [email protected] wrote:

Hello everyone,

I’m using nginx since some days and I got a little trouble. It seems
that after some while of working fine nginx exits the fastcgi-daemon
and whenever I try to call a php site then, it shows me 502 Bad
Gateway.

Then I have to “/usr/bin/php-fastcgi start” and everything runs fine
again.

So basically my question: How do I make the php-fastcgi not exit
itself or how do I make it automatically restart on exit? It’s
annoying that my website everytime turns to “502 Bad Gateway” to
everyone and I don’t even know about that!

Can anyone help me please? :frowning:

Use one of the many init scripts available throughout the
interwebs. Also I suggest monit for monitoring the process.

I now use php-fpm, but before I used the “regular” php-cgi with this
init script: GitHub - perusio/php-fastcgi-debian-script: An init script to launch PHP the FastCGI daemon and spawn when needed in Debian and
a monit configuration for monitoring it:
monit-miscellaneous/php-cgi at master · perusio/monit-miscellaneous · GitHub

HTH,
— appa

Reinis R. Wrote:

rr


nginx mailing list
[email protected]
nginx Info Page

I used to do this and I hat php 5.3 running with apache. But when I
decided to try something new to go with nginx instead of apache, I had
trouble setting up nginx with php as that repository doesnt have the
php-cgi package. Therefor all attempts to get any phpinfo() file run
failed and I was forced to uninstall php 5.3 to install php 5.2. I
wasn’t really happy with that, but at least it works at all… So far
I’m only half-satisfied with nginx, but I’m pretty sure thats just about
the config, nginx sounds fine. Gonne read tons of HowTos and Docs and
stuff I suppose

Posted at Nginx Forum:

as that repository doesnt have the php-cgi package.

You don’t need the -cgi (it is the old naming when fastcgi was built in
the
cgi sapi) package but ‘php5-fpm’ .
Also I think the packages are prefixed with ‘php5’ and called php5-fpm /
php5-cgi ( http://php53.dotdeb.org/dists/lenny/php5/binary-amd64/ )

rr

I’m running Debian Lenny which has only php 5.2 :frowning:

I’m not a Debian user but you could add the dotdeb repo (
PHP 5.3.8 is available – Dotdeb ).
Sticking with old and unsupported php release isnt a good thing.

rr

So I removed php again, putting dotdeb into sources and commenting
debian out, trying to reinstall php5-common, but this appears:

Package php5-common is not available, but is referred to by another
package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

What am I doing wrong now? I did update apt-get after editing sources

Posted at Nginx Forum:

Disregard that, I just directly downloaded the debs with wget. For the
moment its working, thanks alot! I hope it won’t crash down every now
and then anymore.

Thanks alot again to anyone who spent his time in this thread!

Posted at Nginx Forum: