1. The problem I’m having:
Minor background:
We have a server where PHP is “falling over” from time to time. I’ve been able to see that something is causing PHP-FPM to spin up child processes until it hits the max_children
, at which point PHP stops serving anything to any site until PHP is restarted.
The problem I’m trying to solve:
As all the sites share the same PHP-FPM pool (www), there’s no useful information for me to track down where the problem is stemming from. So I am trying to get the PHP-FPM Status page configured, which I am hoping will give me more information so I can at least see which site hosted on the server and possibly what script might be the root cause of the behaviour.
I can’t seem to work out how to configure that in Caddy2, and must admit that this may be as much “not having a clear understanding of the guts of how this works” as it is about “specifically Caddy’s configuration”. The only things I’ve found relating to this are seemingly for “old Caddy”.
For clarity, I can confirm I have edited /etc/php/8.1/fpm/pool.d/www.conf
to enable the line pm.status_path = /status
and have restarted PHP-FPM via systemctl restart php8.1-fpm
. I have also restarted Caddy via sudo systemctl daemon-reload && systemctl reload caddy && systemctl start caddy
2. Error messages and/or full log output:
No ‘Caddy’ errors, I just get a 404 for https://staging.domain.ext/status?html&full
(URL anonymised, but “correct”)
3. Caddy version:
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
4. How I installed and ran Caddy:
- Installed Ubuntu 22.04LTS
- Set up UFW
- Set up Fail2Ban
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update && sudo apt install caddy git
a. System environment:
- Ubuntu 22.04LTS
b. Command:
It runs itself on boot?
c. Service/unit/compose file:
Not relevant
d. My complete Caddy config:
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
#
# Snippets (see: https://caddyserver.com/docs/caddyfile/concepts)
(staticfilecache) {
@static {
file
path *.ico *.css *.js *.gif *.jpg *.jpeg *.webp *.png *.svg *.woff2
}
header @static Cache-Control max-age=5184000
}
staging.domain.ext {
root * /websites/staging
encode gzip zstd
log {
output file /websites/_logs/staging.log
}
php_fastcgi /status unix//run/php/php8.1-fpm.sock {
env SCRIPT_NAME /status
}
file_server
}
other.website.url {
root * /websites/craft4-vca/web
encode gzip zstd
php_fastcgi unix//run/php/php8.1-fpm.sock
file_server
import staticfilecache
log {
output file /websites/_logs/craft4-vca.log
}
}
Above, the domains are not “real” just for security - but in reality both sites work. The first, staging.domain.ext
doesn’t have any PHP scripts but it the one I want to be able to access the FPM Status from. The second isn’t related to this problem but I can confirm that it hosts PHP pages and runs fine.
5. Links to relevant resources:
- PHP: Status Page - Manual PHP’s FPM-Status docs
- An nGinx set up for it How to Enable and Monitor PHP-FPM Status in Nginx