I'm running Wordpress with: Nginx + PHP-FPM + APC + W3 Total Cache + PageSpeed.
After 3 days researching and configuring, I succeeded to make it work. I configured PHP-FPM to run via 127.0.0.1:9000. But now I want to configure via Socket.
The problem is that I can't find the socket path in my server. I just found /var/run/php-fpm/php-fpm.pid
, but php-fpm.sock
was not there.
Running whereis php-fpm
the output is:
php-fpm: /usr/sbin/php-fpm /etc/php-fpm.d /etc/php-fpm.conf /usr/share/man/man8/php-fpm.8.gz
But there isn't any php-fpm.sock
there.
How can I find php-fpm.sock
?
My specs:
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. conf: To list all PHP configuration files, use the following ls command.
To find out php version installed on the server type any one of the following commands on your server. Open the terminal prompt and then type the following commands. Are you using php-fpm? Get php version using the php-fmp -v or php-fpm73 -v command.
I know this is old questions but since I too have the same problem just now and found out the answer, thought I might share it. The problem was due to configuration at pool.d/
directory.
Open
/etc/php5/fpm/pool.d/www.conf
find
listen = 127.0.0.1:9000
change to
listen = /var/run/php5-fpm.sock
Restart both nginx and php5-fpm service afterwards and check if php5-fpm.sock already created.
I faced this same issue on CentOS 7 years later
Posting hoping that it may help others...
Steps:
FIRST, configure the php-fpm settings:
-> systemctl stop php-fpm.service
-> cd /etc/php-fpm.d
-> ls -hal
(should see a www.conf file)
-> cp www.conf www.conf.backup
(back file up just in case)
-> vi www.conf
-> :/listen =
(to get to the line we need to change)
-> i
(to enter VI's text insertion mode)
-> change from listen = 127.0.0.1:9000
TO listen = /var/run/php-fpm/php-fpm.sock
-> Esc
then :/listen.owner
(to find it) then i
(to change)
-> UNCOMMENT the listen.owner = nobody
AND listen.group = nobody
lines
-> Hit Esc
then type :/user =
then i
-> change user = apache
TO user = nginx
-> AND change group = apache
TO group = nginx
-> Hit Esc
then :wq
(to save and quit)
-> systemctl start php-fpm.service
(now you will have a php-fpm.sock file)
SECOND, you configure your server {}
block in your /etc/nginx/nginx.conf
file. Then run:systemctl restart nginx.service
FINALLY, create a new .php file in your /usr/share/nginx/html directory for your Nginx server to serve up via the internet browser as a test.
-> vi /usr/share/nginx/html/mytest.php
-> type o
-> <?php echo date("Y/m/d-l"); ?>
(PHP page will print date and day in browser)
-> Hit Esc
-> type :wq
(to save and quite VI editor)
-> open up a browser and go to: http://yourDomainOrIPAddress/mytest.php
(you should see the date and day printed)
Check the config file, the config path is /etc/php5/fpm/pool.d/www.conf
, there you'll find the path by config and if you want you can change it.
EDIT:
well you're correct, you need to replace listen = 127.0.0.1:9000
to listen = /var/run/php5-fpm/php5-fpm.sock
, then you need to run sudo service php5-fpm restart
, and make sure it says that it restarted correctly, if not then make sure that /var/run/
has a folder called php5-fpm
, or make it listen to /var/run/php5-fpm.sock
cause i don't think the folder inside /var/run
is created automatically, i remember i had to edit the start up script to create that folder, otherwise even if you mkdir /var/run/php5-fpm
after restart that folder will disappear and the service starting will fail.
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