Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was setting-up Nginx with PHP5 on Ubuntu 10.04.4 TLS Server, and follow this instructions -

http://library.linode.com/web-servers/nginx/php-fastcgi/ubuntu-10.04-lucid

Everything is fine before I run /etc/init.d/php-fastcgi start, the php-fastcgi is a script -

#!/bin/bash

PHP_SCRIPT=/usr/bin/php-fastcgi
FASTCGI_USER=www-data
FASTCGI_GROUP=www-data
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

and it give me this message -

spawn-fcgi: opening PID-file '/var/run/php-fastcgi/php-fastcgi.pid' failed: No such file or directory

Apparently there is no php-fastcgi.pid in the folder, even strange, there is no php-fastcgi folder in /var/run, I installed php by this command -

apt-get install php5-cli php5-cgi spawn-fcgi psmisc

So is there anything wrong? Thanks.

share|improve this question
    
Does the directory, /var/run/php-fastcgi/ exist, and is it writable by the www-data user? –  Christopher Jan 21 '13 at 17:52
    
It doesn't exist, did you mean I should create one? –  Tom Jan 21 '13 at 18:38
    
Yes. :) (sudo mkdir /var/run/php-fastcgi/; sudo chgrp www-data /var/run/php-fastcgi/; sudo chmod 0770 /var/run/php-fastcgi/ should do it.) –  Christopher Jan 21 '13 at 18:39
    
Thank u very much, it's working!! –  Tom Jan 21 '13 at 18:42
    
Can u answer the question, and then I can choose your answer? –  Tom Jan 21 '13 at 18:43
show 1 more comment

1 Answer

up vote 1 down vote accepted

Create the missing directory and make it writable by the web server user:

sudo mkdir /var/run/php-fastcgi/
sudo chgrp www-data /var/run/php-fastcgi/
sudo chmod 0770 /var/run/php-fastcgi/
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.