Using the php-fpm-wordpress.sock socket outside of Wordpress?

Hi there,

I’m trying to setup monitoring on PHP-FPM (7.4), and I just can’t get it to work. On all my non-Trellis servers, it’s just a matter of enabling it in www.conf and then pointing NGINX at the socket, which is usually at /var/run/php7.4-fpm.sock. Clearly, Trellis sets up a separate socket at php-fpm-wordpress.sock. This works well with my Wordpress sites, obviously, but I don’t seem to be able to reference that from within any other application or from NGINX, and I’m not quite sure why. I’m sure I’m missing something obvious, like permissions, but any light anyone could shed on this would be welcome.

Thanks!

Hey @charlestroluxe! You should be able to modify the Trellis Nginx/PHP configs in order to pull off what you’re trying to accomplish

Could you let us know which files you’ve modified/what you’ve tried out so far? What monitor are you trying to setup?

Thanks for the reply.

PHP-FPM

To enable a status page within PHP-FPM, I added this into roles/wordpress-setup/templates/php-fpm.conf.j2:

pm.status_path = {{ php_fpm_pm_status_page }}

Then I added this into group_vars/staging/main.yml (I’m testing this on staging, but would use production’s main.yml file, too, once it’s working):

php_fpm_pm_status_page: /status

Then I ran ansible-playbook server.yml -e env=staging --tags wordpress-setup to push it to the staging server.

I then manually checked that the line had been added to /etc/php/7.4/fpm/pool.d/wordpress.conf, which it had, within the [wordpress] section.

NGINX

I then amended the staging.conf.child file within my nginx-includes/all folder so that there is an entry that points to PHP-FPM. That entry reads:

server  {
        listen 80;
        location /status {
        allow 127.0.0.1;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_pass   unix:/etc/php/7.4/fpm/pool.d/wordpress.sock;
}}

I then manually checked that the entry had been added to /etc/nginx/nginx.conf, which it had.

Testing

But when I try to go to http://127.0.0.1/status, I get a 404.

I’m not sure why, because, in the same staging.conf.child file, I have NGINX-monitoring setup, with:

server  {
        listen 80;
        location /basic_status {
            stub_status on;
            allow 127.0.0.1;
            deny all;
        }
        }

And that works.

If I put those two into the same server block, I get a 502 instead:

server  {
        listen 80;
        location /basic_status {
            stub_status on;
            allow 127.0.0.1;
            deny all;
        }

        location /status {
        allow 127.0.0.1;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_pass   unix:/etc/php/7.4/fpm/pool.d/wordpress.sock;
        }
        }

FYI: My Wordpress sites in Trellis are running on a different port, so it’s not that they’re interfering in some way with the requests on port 80.

And, of course, I’ve just realized what I’m doing wrong. I had the PHP-FPM socket as unix:/etc/php/7.4/fpm/pool.d/wordpress.sock, when, of course, it’s actually unix:/var/run/php-fpm-wordpress.sock.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.