Trying to get php working

I have a directive in /etc/caddy/Caddyfile: {
        fastcgi / unix:/run/php-fpm/php-fpm.sock php

I have php-fpm installed and running on Arch. I’m running caddy as a systemd service. My DNS is configured and a mediawiki installation is in the root directory. Navigating to my URL Caddy produces:

502 Bad Gateway

Check the /var/run/php5-fpm.sock path?

I think the default is listen = /run/php-fpm/php-fpm.sock on Archlinux btw. I prefer just the port way.

So please try fastcgi / unix:/run/php-fpm/php-fpm.sock php

Otherwise I highly recommend the abiosoft/caddy:php docker image. Good luck!

1 Like

You were correct, double checked that both were /run/php-fpm/php-fpm.sock and restarted both - no dice.

After hours of fucking around with this, I’ve gotten PHP working if I run caddy -conf="/my/conf/Caddyfile", but when I start it with systemctl start caddy it won’t come up.

This is extremely frustrating, I don’t understand why it just doesn’t work.

Try pasting here your systemd service file so we can take a look at it

I suspect it’s a permissions error causing the start job to fail.

Here is my Caddyfile:

/etc/caddy/Caddyfile {
	root /var/www/
	log access.log (this sometimes give a permission error in journalctl)
	errors errors.log
	fastcgi / unix:/var/run/php-fpm/php-fpm.sock php

journalctl says it starts and then immediately dies, so it most be a config issue.
Here is my service:

Description=Caddy HTTP/2 web server
Documentation= systemd-networkd-wait-online.service


; User and group the process will run as.

; Letsencrypt-issued certificates will be written to this directory.

; Always set "-root" to something safe in case it gets forgotten in the Caddyfile.
ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
ExecReload=/bin/kill -USR1 $MAINPID

; Limit the number of file descriptors; see `man systemd.exec` for more limit settings.
; Unmodified caddy is not expected to use more than that.

; Use private /tmp and /var/tmp, which are discarded after caddy stops.
; Use a minimal /dev
; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys.
; Make /usr, /boot, /etc and possibly some more folders read-only.
; … except /etc/ssl/caddy, because we want Letsencrypt-certificates there.
;   This merely retains r/w access rights, it does not add any new. Must still be writable on the host!

; The following additional security directives only work with systemd v229 or later.
; They further retrict privileges that can be gained by caddy. Uncomment if you like.
; Note that you may have to add capabilities required by any plugins in use.


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