Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
Restarting spawn-fcgi after bad-gateway errorsKyle Deneen, 07-30-2008 |
Many people running a web server using Nginx/spawn-fcgi/PHP-FCGI platform, have probably come across bad gateway errors when trying to serve PHP documents. In particular, this error is problematic when you are hosting APIs or client websites on such a server. We have created a simple shell script that will allow you to quickly issue a single command on your shell to restart spawn-fcgi, without all the manual commands you normally would need to issue:
The arguments can vary from server to server. The first command kills all the spawn-fcgi processes. On your server, this could be "php", "php-fcgi" or something different. Typically speaking, this is the name of your PHP-FCGI binary, without the path. So if your PHP-FCGI binary is /usr/local/bin/php, then your killall command would be:
Try issuing a 'ps aux' to determine the location of your php-fcgi binary.
The second command would be the path to your spawn-fcgi startup script, which you should have somewhere under rc.d for automatic start-up on boot. The path/name of this script can obviously vary from server-to-server and OS-to-OS.
Simply save the first 2 commands listed in this post to a file and give it sufficient permissions, such as "chmod 777 restart-spawnfcgi.sh". This way, when you get those nasty bad gateway errors, you can quickly log on to your server and execute that script to get the server back online and serving PHP-FCGI quickly and easily.
killall -m "php-fcgi"
/usr/local/etc/rc.d/spawn-fcgi.sh
/usr/local/etc/rc.d/spawn-fcgi.sh
The arguments can vary from server to server. The first command kills all the spawn-fcgi processes. On your server, this could be "php", "php-fcgi" or something different. Typically speaking, this is the name of your PHP-FCGI binary, without the path. So if your PHP-FCGI binary is /usr/local/bin/php, then your killall command would be:
killall -m "php"
Try issuing a 'ps aux' to determine the location of your php-fcgi binary.
The second command would be the path to your spawn-fcgi startup script, which you should have somewhere under rc.d for automatic start-up on boot. The path/name of this script can obviously vary from server-to-server and OS-to-OS.
Simply save the first 2 commands listed in this post to a file and give it sufficient permissions, such as "chmod 777 restart-spawnfcgi.sh". This way, when you get those nasty bad gateway errors, you can quickly log on to your server and execute that script to get the server back online and serving PHP-FCGI quickly and easily.
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

