Can't start since Php + service installed

Hi all,

1. Caddy version (caddy version):

Last version

2. How I run Caddy:

a. System environment:

I’ve got Raspberry 3b+ with Raspbian + VNCServer + Syncthing + Minidlna + 2 Sata HDD and decided to install a faster webserver Caddy.
I’ve got another Raspberry 3b+ without VNCServer + Syncthing + Minidlna but Apache2 is too slow even for a small website.

What i did:

I followed install guide of Caddy + Php from PiMyLifeup .

In the middle of installation (), there is a test: i could see my index.html page from my localhost. Both through VNC or from my laptop html page is visible and incredible fast !

b. Command:

When Caddy was installed alone without Php + Service, i launched caddy as below:

cd /etc/caddy

It was OK and could be able to see index.html page by a browser.

After, i installed Php + service as described from Pimylifeup to be able to execute Php script from my website and start caddy as a service while Raspberry boot:

sudo service caddy start

In that cas, now, if i launch this command , i get errors. see paragraph 3.

c. Service/unit/compose file:

d. My Caddyfile + caddy.service:

File CaddyFile

:80 localhost:80 {
root /media/data_sata2/www

fastcgi / /var/run/php/php7.3-fpm.sock {
    index index.php
rewrite {
    r .*
    ext /
    to /index.php?{query}


File caddy.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!

; Drop all other capabilities. Important if you run caddy as privileged user (which you should not).
; … but permit caddy to open ports reserved for system services.
; This could be redundant here, but is needed in case caddy runs as nobody:nogroup.
; … and prevent gaining any new privileges.

; Caveat: Some plugins need additional capabilities. Add them to both above lines.
; - plugin “upload” needs: CAP_LEASE


3. The problem I’m having:

I can not more start Caddy since i installed Php module + declare Caddy as a service as described on PimpMyLife.
if i launch brower with http:// ip /index.html i get HTTP 502 Bad gateway message and no more render of this HTML page as seen previously.

4. Error messages and/or full log output:

I get error:

from Journalclt :

May 07 15:04:15 raspberrypi systemd[1]: Started Caddy HTTP/2 web server.
May 07 15:04:15 raspberrypi systemd[1]: Starting Network Service…
May 07 15:04:15 raspberrypi systemd[13135]: caddy.service: Failed to set up mount namespacing: No such file or directory
May 07 15:04:15 raspberrypi systemd[13135]: caddy.service: Failed at step NAMESPACE spawning /usr/local/bin/caddy: No such file or di
May 07 15:04:15 raspberrypi sudo[13128]: pam_unix(sudo:session): session closed for user root
May 07 15:04:15 raspberrypi systemd[1]: caddy.service: Main process exited, code=exited, status=226/NAMESPACE
May 07 15:04:15 raspberrypi systemd[1]: caddy.service: Failed with result ‘exit-code’.

From prompt (Putty)

2020/05/07 15:05:09 [ERROR 502 /index.php] dial unix /var/run/php/php7.3-fpm.sock: connect: permission denied
2020/05/07 15:05:27 [ERROR 502 /index.php] dial unix /var/run/php/php7.3-fpm.sock: connect: permission denied

5. What I already tried:

I checked caddy.service file , checked journalctl logs
and rights on my localhost directory.

Why is there no directory:
/usr/local/bin/caddy as requested from ExecStart on caddy.service?

I didn’t able to look for solution.

What do you suggest?

Thanks for your help?



Hi @NormandiePI1, welcome to the Caddy community!

From your journalctl output, it looks like Caddy straight up isn’t starting because there’s no /usr/local/bin/caddy executable for the service to run.

Suggest you go review the PiMyLifeup guide you followed, you may have missed steps (namely, placing the Caddy binary in the location specified by the unit file).

1 Like

Also FYI, you say:

But everything you write afterwards are instructions for Caddy v1. The latest is Caddy v2, which is a complete rewrite of the project.


Dear all,
Thanks a lot for your time and your answers to both.
Shame on me. Too busy and i didn’t see there were a big jump version from Caddy to Caddy2.
Today (i’m in ouest of France), i’ll check to review fully my install for Caddy2.
Thanks again. I’ll revert when my install will be finished.

Thanks again all.
My Caddy server 2.0 is OK at this stage.


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