how to create php-fastcgi.sock for Nginx
Solution 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.
Solution 2
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
Related videos on Youtube
Syme0n
Updated on September 18, 2022Comments
-
Syme0n over 1 year
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!!
-
slm almost 10 yearsFollow the steps from the Nginx website for FastCGI setup: wiki.nginx.org/PHPFcgiExample
-
-
Syme0n almost 10 yearsok, 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...
-
Syme0n almost 10 yearsBTW, in the init script for fastcgi, I included BIND=127.0.0.1:9000, do I have to change that??
-
cuonglm almost 10 years@Digitalsite: you only create folder, not the socket file.
-
Syme0n almost 10 yearsok, then how do I know if the socket is working or not!! please explain a little if possible.
-
Syme0n almost 10 yearsit still gives me
connect() to unix:/var/run/php-fastcgi/php-fastcgi.socket failed
-
Syme0n almost 10 yearsI changed the user the nginx.conf to root and change as well permission /var/run/php-fastcgi/ and restarted both fastcgi and nginx, but the same exact issue is still showing up!!
-
cuonglm almost 10 years@Digitalsite: Did you config
php-fpm
listen on unix socket instead of tcp? See: php.net/manual/en/install.fpm.configuration.php