3

Summary:I'm trying to use Nginx on PHP7.2 and CentOS 7, but can't find php-fpm.sock

I used to use PHP7.0 on Ubuntu 16. Recently, I switched to CentOS 7. and now I'm trying to set it up with Nginx and the latest PHP (i.e. PHP7.2)

On PHP7.0 on Ubuntu 16, the php-fpm's socket file was stored in...

/run/php/php7.0-fpm.sock

However, on PHP7.2. and CentOS7, I don't see /run/php/ directory. So, it's clear that Nginx on PHP7.2 and CentOS can't be configured in the say way

I searched Stackoverflow, but most of the posts were dealing with older versions of php (like this one)

If I run yum install php-fpm, it results in "already installed", so I'm sure php-fpm itself is already there

enter image description here

If I run "ps aux | grep php-fpm"...

enter image description here

I can see that there is a directly, named /etc/php-fpm.d, but it has only a file called www.conf, not a socket file.

This tutorail shows that the sock is stored as /run/php-fpm/www.sock on PHP7.2 and CentOS 7, but in my machine, there is only php-fpm.pid.

So, where did the sock file go? Any advice will be appreciated.

PS:I'm also interested in why Ubuntu+PHP7 and CentOS+PHP7.2 have such a difference regarding where to store PHP files

Hiroki
  • 3,893
  • 13
  • 51
  • 90

1 Answers1

4

The two distros (Ubuntu and CentOS) are using different package mechanisms (apt vs yum), different packages and different maintainers with different approach to things. So you may expect quite some difference in how things are structured or even work between the two systems.

The default PHP-FPM config by Remi, indeed has one pool listening on port 9000 (AFAIK).

If you want it to listen on a Unix socket, you have to adjust the PHP-FPM pool config. That is /etc/php-fpm.d/www.conf. So you'll want to specify there:

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

This is just to give you an idea :)

Danila Vershinin
  • 8,725
  • 2
  • 29
  • 35
  • FYI: when CentOS 7 was release, apache HTTP server version doesn't have UDS support, the reason why we choose to use a network socket for better compatibility. Switch to UDS is now possible as supported by both httpd and nginx. See: https://developers.redhat.com/blog/2017/10/25/php-configuration-tips/ (§ 1.4.2) – Remi Collet Feb 21 '19 at 11:17
  • 1
    More info: On Fedora and on upcoming EL-8 (8-beta is released), FPM use UDS, and both httpd and nginx use it, with the proper configuration provided (work out-of-the-box, without any change) – Remi Collet Feb 21 '19 at 12:01