If you realize that your PHP FastCGI process keeps dying for no reason this article may help you solve this issue.
Why does my PHP FastCGI keep on dying?
One possible cause is that some other process is taking too much of the memory, and somehow that process kills the PHP FastCGI process or disables the PHP FastCGI process from respawning. In my situation it is the mysqld process. Below is a screenshot showing that the mysqld process, or MySQL daemon, is consuming more than 50% of the entire memory of the machine.
My php5-cgi process would shut down every couple of days, and I'd get a 502 Bad Gateway error when I try to access my website. To fix it I simply restart my php5-cgi process via the following Unix command.
sudo /etc/init.d/php-fastcgi restart
However this is only an interim fix. The permanent fix would not require that I reboot the PHP FastCGI process every now and then. Read on to see how I fixed the problem.
Solution
So the general solution is run top command and see what processes are consuming unreasonable amounts of memory, and take action to drive the memory consumption down.
In my situation I took some steps to make sure my MySQL daemon is no longer consuming too much memory. These steps are described in another post: Best Practices With MySQL Memory Tables to Minimize Memory Footprint of mysqld! The following screenshot shows that my MySQL daemon process is consuming normal amounts of memory.
My problem is fixed! My php5-cgi process no longer shuts down once every couple of days.
Related Articles
Best Practices With MySQL Memory Tables to Minimize Memory Footprint of mysqld!
Save MySQL Daemon Process's Memory Usage By Making VARCHAR Columns Smaller!
Best Practices With MySQL Memory Tables to Minimize Memory Footprint of mysqld!
Save MySQL Daemon Process's Memory Usage By Making VARCHAR Columns Smaller!
Your situation may be different. If you need help just let me know!