Settings Caddy for php7.1-fpm

Hello everyone! I need a help.

I get 502 Bad Gateway. Prompt where to dig?
Thanks for all.

My Caddyfile:

In workspace one php file:

Him content is:

But the same settings work in MacOS.

Is PHP-FPM enabled and listening on port 9000?

1 Like

Problem is successfully solved!
In file /etc/php/7.1/fpm/pool.d/www.conf it was not spelled out listen =, was spelled only listen = /run/php/php7.1-fpm.sock.

I just tried using the first option to connect.

Thank you for paying attention to my topic. Below I posted the answer. :smile:
As far as I remember, in earlier versions it was written listen =

1 Like

Optionally, you could leave php7.1 in a default state and configure Caddy to connect to the socket:

fastcgi / unix:/run/php/php7.1-fpm.sock php

While I do not understand why, but this fastcgi / unix:/run/php/php7.1-fpm.sock php doesn’t work.
But I would like to use socket.

Just double-checked the syntax, that’s the correct usage.

Did you change /etc/php/7.1/fpm/pool.d/www.conf back to listen = /run/php/php7.1-fpm.sock?

But I get 502 status.

Comment out listen = in pool.d - I’m not sure, but I suspect it might be overwriting the previous value.

1 Like

Didn’t work. I saw settings when it was two comments and it worked.

Ahh, ok.

What user is Caddy running under? The socket permissions are set only to be readable by www-data.

1 Like

Hmm, not quite what I meant. See listen.owner and in pool.d - in combination with the default listen.mode of 0660, a process can’t read from /run/php/php7.1-fpm.sock unless its user or group is www-data.

That means Caddy itself - not PHP - needs to be run as www-data (or root), or it won’t be able to read from the socket (and it will timeout, generating 502s).

1 Like

I see that comment ;listen.mode = 0660, may be it is problem…
Or change settings on my home user…
I also tried to run the Caddy from different users.

Did you try www-data, specifically?

Ahh, I see you did. Hmm. And your PHP page didn’t work for either www-data or root?

Yes, it is dosn’t work. But usually I run just a home user, whitout sudo.

Strange, especially if it didn’t work as root, which heavily implies PHP-FPM wasn’t listening on the socket at all.

I’m not sure what else to try, I’m afraid.

Problem solved, the socket works!
I have deleted comment out listen =
Switched to user www-data using sudo -su www-data, then run caddy command caddy.
You were right!

Thank you very much, Matthew! Strong health, man!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.