Settings Caddy for php7.1-fpm

Hello everyone! I need a help.

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

https://drive.google.com/open?id=1LKb5NbHQOAUpUBvoMcgPRd9ujIBb-2xu

My Caddyfile:

https://drive.google.com/open?id=14ZJXncJrT0gG1OZi4hPocez2DYK8FgOo

In workspace one php file:

https://drive.google.com/open?id=1Cd_gVjzY5QiIMG6W1LHxDkDC7G3oQdqY

Him content is:

https://drive.google.com/open?id=1zHdPJrh95h4Htoo-UAv7eJ5P9Gv1cqhO

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 = 127.0.0.1:9000, 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 = 127.0.0.1:9000.

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?

https://drive.google.com/open?id=1NL5lNEyFfCephG5whnENDfkO4JrgM8Zb
https://drive.google.com/open?id=1x5AZRIahhGhdgRz48w6TkVa5aQ1L8QXT

But I get 502 status.

Comment out listen = 127.0.0.1:9000 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

https://drive.google.com/open?id=1TTnWeh1qYdmgYYt6Q9i_GYUSf1E5ErtK
https://drive.google.com/open?id=1wJ9SBh2B_mhRo4Il9QgzVZyhNItQM6_r

Hmm, not quite what I meant. See listen.owner and listen.group 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

https://drive.google.com/open?id=1Dk6EZkfkTI6zjr7TK_kI2eLjQ1sAvH9V
https://drive.google.com/open?id=1EZyz_R5pb0mPVh3cl2BlkIMEYh4JjLPq

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.

Cheers!
Problem solved, the socket works!
I have deleted comment out listen = 127.0.0.1:9000.
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.