nginx + php-fastcgi: fastcgi suddenly not working
Output of starting, stopping and checking the status of php-fastcgi:
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:
#!/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
#!/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
7 Replies
What do you get when you manually run the spawn-fcgi program as in the last line of /usr/bin/php-fastcgi?
It also seems that you're using an overly complicated setup. Init script calling another bash script? What for? If you're using spawn-fcgi on Debian Squeeze, you only need one init script. Here
Regardless of if I run the init script, the bash script in /usr/bin, or the command, I get:
spawn-fcgi: child signaled: 11
I've no idea what this is, but the PID file generated is empty. I also get the same output from your script, and it produces an empty file called /var/run/spawn-fcgi.pid. When I tell both scripts to stop, they delete their respective PID files and complain that they don't have a process to kill.
I was following the tutorial in the Linode Library, which has me create both scripts:
At this point, I'd be trying php-fpm, except it's not in Debian's repos and I don't feel like compiling something else
I ran "dpkg -l | grep php" and removed anything that showed up. I then added the dotdeb.org repositories (which I found after several minutes of searching) and reinstalled php from there, and included php5-fpm. I reconfigured nginx to use that, and the site works fine now. I'm still baffled as to what happened to make fastcgi stop working – the only packages I had installed were php5-cli, php5-common, php5-cgi, php5-mcrypt, and spawn-fcgi. It's probably too late to do investigating, I tend to purge packages rather than just removing them.
I bet one of your extensions got corrupted in a recent update. It can happen, especially if you mix distro binaries with self-compiled binaries. You could have tried reinstalling all of them, but it's a moot point now that you've moved on to Dotdeb.