How to find my php-fpm.sock?

To find your PHP-FPM socket file, you will need to first determine the location of your PHP installation. You can do this by running the following command:

which php

This should output the path to the PHP binary. For example:

/usr/local/bin/php

Watch a course Learn object oriented PHP

Next, you will need to check your PHP configuration for the value of the listen directive. This directive specifies the location of the PHP-FPM socket file. You can check the value of this directive by running the following command:

php -i | grep "^listen"

This should output a line similar to the following:

listen => /var/run/php-fpm.sock

The value after => is the path to your PHP-FPM socket file. In this case, the socket file is located at /var/run/php-fpm.sock.

If the php -i command does not return a value for the listen directive, you can try looking for the listen.mode directive instead:

php -i | grep "^listen.mode"

This directive specifies the type of socket that PHP-FPM is using, which can be either unix or tcp. If the value of this directive is unix, you can find the path to the socket file by looking for the listen.owner and listen.group directives:

php -i | grep "^listen.owner"
php -i | grep "^listen.group"

These directives specify the owner and group of the socket file, respectively. The socket file itself is typically located in a directory that is owned by the same user and group, such as /var/run or /run. You can use the values of these directives to determine the location of the socket file.

I hope this helps! Let me know if you have any other questions.