2

I've installed Debian Wheezy and downgraded php5.4 to php5.3, and wanted to use fastCgi instead of php-fpm since it is not included in php5.3 package.

now I run into a little issue and can't seem to find a way around it. This issue is unix:/var/run/php-fpm/php-fpm.sock can't be created.

I have created a file for UNIX socket /usr/bin/php-fastcgi

#!/bin/bash

FASTCGI_USER=www-data
FASTCGI_GROUP=www-data
SOCKET=/var/run/php-fastcgi/php-fastcgi.socket
PIDFILE=/var/run/php-fastcgi/php-fastcgi.pid
CHILDREN=6
PHP5=/usr/bin/php5-cgi

/usr/bin/spawn-fcgi -s $SOCKET -P $PIDFILE -C $CHILDREN -u $FASTCGI_USER -g $FASTCGI_GROUP -f $PHP5

And this my Nginx vhost:

server {
    server_name www.mydomain.com mydomain.com;
    root /srv/www/www.example.com/public_html;

    location / {
        index  index.html index.htm;
    }

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    }
}

The main issue is always this:

connect() to unix:/var/run/php-fastcgi/php-fastcgi.socket failed (2: No such file or directory)

And this is for Enable and Start fastcgi service:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          php-fcgi
# Required-Start:    $nginx
# Required-Stop:     $nginx
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php over fcgi
# Description:       starts php over fcgi
### END INIT INFO

(( EUID )) && echo .You need to have root priviliges.. && exit 1
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=10
PHP_FCGI_MAX_REQUESTS=10000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
      echo -n "Starting PHP FastCGI: "
      start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}
stop() {
      echo -n "Stopping PHP FastCGI: "
      killall -q -w -u $USER $PHP_CGI
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}

case "$1" in
    start)
      start
  ;;
    stop)
      stop
  ;;
    restart)
      stop
      start
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL

I'm wondering what is missing??

any comment is appreciated!!

1

2 Answers 2

1

nginx will create php-fastcgi.socket for you, but it must have permission to write in directory which you defined in config file.

As root, try:

mkdir /var/run/php-fastcgi
chown www-data:www-data /var/run/php-fastcgi
7
  • ok, if created that file, then what should I expect Nginx to do? would it create the socket? because I don't see anything in that folder... Jun 28, 2014 at 7:50
  • BTW, in the init script for fastcgi, I included BIND=127.0.0.1:9000, do I have to change that?? Jun 28, 2014 at 7:51
  • @Digitalsite: you only create folder, not the socket file.
    – cuonglm
    Jun 28, 2014 at 7:55
  • ok, then how do I know if the socket is working or not!! please explain a little if possible. Jun 28, 2014 at 7:58
  • 1
    @Digitalsite: Did you config php-fpm listen on unix socket instead of tcp? See: php.net/manual/en/install.fpm.configuration.php
    – cuonglm
    Jun 28, 2014 at 11:13
1

Change the init script to bind on a socket by changing the 127.0.0.1:9000 to your full path and socket filename.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .