I am running Debian Squeeze. I compiled nginx 1.0.5 since the one in Debian's repository was out of date, and I setup the fastcgi scripts in /usr/bin/php-fastcgi and /etc/init.d/php-fastcgi as per the Linode Library's article for php-fastcgi. This setup worked fine for about a month, but the nginx started giving my browser the "502 Bad Gateway" message. It does not appear in top, and I double checked the output of "ps -A | grep php ; ps -A | grep fastcgi ; ps -A grep spawn", and saw no output. The .pid file does exist in the /var/php-fastcgi when I start php-fastcgi, and disappears when I stop it; the process does not show up after starting it.
Output of starting, stopping and checking the status of php-fastcgi:
Code:
root@li283-45:~# /etc/init.d/php-fastcgi start
spawn-fcgi: child signaled: 11
root@li283-45:~# /etc/init.d/php-fastcgi status
php-fastcgi running with PID
root@li283-45:~# /etc/init.d/php-fastcgi stop
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
root@li283-45:~# /etc/init.d/php-fastcgi status
Could not find PID file /var/run/php-fastcgi/php-fastcgi.pid, php-fastcgi does not appear to be running
Steps I took to troubleshoot:
- I ssh'ed to my Linode to restart php-fastcgi, but it does not appear to be running after I start it.
-I reinstalled spawn-fcgi via apt-get (apt-get purge spawn-fcgi && apt-get install spawn-fcgi) to no avail.
-I also removed the scripts that I added from Linode Library and re-added them with a direct copy-and-paste as before, and adjusted the user and group to the ones I'm using for my nginx server (I'm using www, not www-data, and I triple-checked these were correct in the scripts, everything else is exactly the same).
Here are my scripts:
/etc/init.d/php-fastcgi:
Code:
#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
FASTCGI_USER=www
FASTCGI_GROUP=www
PID_DIR=/var/run/php-fastcgi
PID_FILE=/var/run/php-fastcgi/php-fastcgi.pid
RET_VAL=0
case "$1" in
start)
if [[ ! -d $PID_DIR ]]
then
mkdir $PID_DIR
chown $FASTCGI_USER:$FASTCGI_GROUP $PID_DIR
chmod 0770 $PID_DIR
fi
if [[ -r $PID_FILE ]]
then
echo "php-fastcgi already running with PID `cat $PID_FILE`"
RET_VAL=1
else
$PHP_SCRIPT
RET_VAL=$?
fi
;;
stop)
if [[ -r $PID_FILE ]]
then
kill `cat $PID_FILE`
rm $PID_FILE
RET_VAL=$?
else
echo "Could not find PID file $PID_FILE"
RET_VAL=1
fi
;;
restart)
if [[ -r $PID_FILE ]]
then
kill `cat $PID_FILE`
rm $PID_FILE
RET_VAL=$?
else
echo "Could not find PID file $PID_FILE"
fi
$PHP_SCRIPT
RET_VAL=$?
;;
status)
if [[ -r $PID_FILE ]]
then
echo "php-fastcgi running with PID `cat $PID_FILE`"
RET_VAL=$?
else
echo "Could not find PID file $PID_FILE, php-fastcgi does not appear to be running"
fi
;;
*)
echo "Usage: php-fastcgi {start|stop|restart|status}"
RET_VAL=1
;;
esac
exit $RET_VAL
/usr/bin/php-fastcgi
Code:
#!/bin/bash
FASTCGI_USER=www
FASTCGI_GROUP=www
ADDRESS=127.0.0.1
PORT=9000
PIDFILE=/var/run/php-fastcgi/php-fastcgi.pid
CHILDREN=6
PHP5=/usr/bin/php5-cgi
/usr/bin/spawn-fcgi -a $ADDRESS -p $PORT -P $PIDFILE -C $CHILDREN -u $FASTCGI_USER -g $FASTCGI_GROUP -f $PHP5