Blog Linux NGINX PHP

nginx - 502: bad gateway

One of my VPS on NordicPVS went down today and after restarting, I got a number of weird errors. Apparently, the contents of my VPS were wiped-out. Though I managed to solve most of the problems (mostly by restoring the backup), I kept getting the 502: Bad Gateway error. I told myself that this can't happen because I restored the whole system from the backup already.

After going through a checklist, I found out that PHP CGI is not running. All I had to do is jumpstart it and everything is working as before.

/etc/init.d/php_cgi start

The experience thought me some valuable lessons. I list some below.

  1. Make a regular backup. This saved me from a lot of trouble. If I didn't have the backup, all the data will be gone. And make sure you have an offsite backup.

  2. Keep your system updated. I found out that my nginx is outdated(I installed using the repository). If possible, compile instead of install

  3. Create a checklist of things so that in times of fuckups like what happened earlier today, you have a guide on what to check

  4. Schedule essential programs in the startup. When I setup my vps, I just followed someone else's procedure. Unfortunately, the chkconfig portion was omitted. And being a noob, I didn't know how to set that up. So, RTFM.