I have a simple project with directory structure
I am setting up nginx config for my drupal site, and for the fastcgi_pass
I have been using 127.0.0.1:9000
but I want to use a unix socket as suggested in this conf:
# PHP 7 socket location.
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
but I can't find php/php7.0-fpm.sock;
I have the following path in my centos distro
/var/run/php-fpm/php-fpm.pid
For example, on CentOS 8, with a single version, all PHP configuration files are located in the /etc directory and the default PHP-FPM pool (www) configuration file is /etc/php-fpm. d/www.
server-side, HTML-embedded scripting language (FPM-CGI binary) This package provides the Fast Process Manager interpreter that runs as a daemon and receives Fast/CGI requests. Note that MOST Apache users probably want the libapache2-mod-php7. 0 package.
First open the php-fpm configuration file and enable the status page as shown. Inside this file, find and uncomment the variable pm. status_path = /status as shown in the screenshot. Save the changes and exit the file.
Check the php-fpm config where the socket will be created with:
$ cat /etc/php/7.0/fpm/pool.d/www.conf
Look for listen
, for example:
listen = /run/php/php7.0-fpm.sock
php-fpm creates the socket file after you started the process.
sudo service php7.0-fpm stop
sudo service php7.0-fpm start
Check the directory if socket file was created:
$ cd /run/php && ls -la
First check if php-fpm
is running on your system, for doing this you could use pgrep
for example:
# pgrep -fa php-fpm
5666 php-fpm: master process (/etc/php-fpm.conf)
5667 php-fpm: pool www
5668 php-fpm: pool www
5669 php-fpm: pool www
5670 php-fpm: pool www
5671 php-fpm: pool www
In this case, it shows is up and running and using the configuration file /etc/php-fpm.conf
. Before checking the configuration file and trying to check for the listen =
directive you could quickly look into /proc/net/unix
for example:
# grep php /proc/net/unix
Which may return something like:
ffff8800bfb2f400: 00000002 00000000 00010000 0001 01 28561 /tmp/php-fpm.sock
In this case, it shows that the path for the php-fpm socket is located in /tmp/php-fpm.sock
the one could be verified by checking the conf in /etc/php-fpm.d/www.conf
in this case being: listen= /tmp/php-fpm.sock
In case you don't get any result and php-fpm
is up and running, by checking the configuration you may find that is using the defaults by listing on a TCP socket:
listen = 127.0.0.1:9000
Something you could change to listen on a Unix socket like your suggested conf:
listen = /var/run/php/php7.0-fpm.sock
In some Linux distros normally this is used:
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
After modifying your configuration don't forget to restart the services systemctl restart php-fpm
. To check that the socket has been created you could do:
$ file /var/run/php/php7.0-fpm.sock
If socket exists if should print out something like this:
/var/run/php/php7.0-fpm.sock: socket
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With