Quantcast
Viewing all articles
Browse latest Browse all 11

‘502 Bad Gateway’ when running WordPress with spawn-fcgi nginx php

I am running a WordPress blog using nginx + PHP + spawn-fcgi and it works fine, but once a day spawn-fcgi seems to crash.

This is not so good, because then there is always the need to restart the spawn-fcgi process, which is annoying if you need to do this manually. So I thought it might be good to to this in a automatic way.

Note: This is not a real solution for this problem, because it doesn’t resolve the problem it just saves you some time. Image may be NSFW.
Clik here to view.
😉

A nice & easy way is to use monit as a proactive monitoring solution for this. Because I am using Debian I will install it using:

apt-get install monit

After that we have the files

  • /etc/default/monit and
  • /etc/monit/monitrc
Now we can create a configuration for monit in /etc/monit/conf.d. Let’s name it spawn_fcgi.conf. The task of this configuration is to check for the spawn-fcgi process. So the content would look like e.g.
In general this means: check every 60 second for a running mydomain.com on port 80 and if it’s not running restart spawn-fcgi.
Because I have not a startup script in /etc/init.d/ for spawn-fcgi i created one in /opt for me:
In /etc/default/monit we need to set startup=1 to be able to start monit and then start monit via
/etc/init.d/monit start
We are done.
About monit:

Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.

The post ‘502 Bad Gateway’ when running WordPress with spawn-fcgi nginx php appeared first on Happy Coding Journal.


Viewing all articles
Browse latest Browse all 11

Trending Articles