What is wrong with this config?

1. Caddy version (caddy version):

2

2. How I run Caddy:

I’m not sure what you mean by this. I have caddy v2 installed on Alma Linux VPS. I also have php 7.4 (including php-fpm and php-cgi) installed. I started caddy using

systemctl enable --now caddy

after setting up the Caddyfile and copying my php file into the docroot.

a. System environment:

Alma Linux

b. Command:

systemctl start caddy

c. Service/unit/compose file:

nope

N/A

d. My complete Caddyfile or JSON config:

sub1.mydomain.co.uk:80
root * /var/www/html/sub1/webroot
php_fastcgi unix//run/php-fpm/www.sock
file_server
log {
        output file /var/log/caddy/access.log
}
sub2.mydomain.co.uk:80
root * /var/www/html/sub2/spa
php_fastcgi unix//run/php-fpm/www.sock
file_server
log {
        output file /var/log/caddy/access.log
}

3. The problem I’m having:

Caddy won’t start

4. Error messages and/or full log output:

Job for caddy.service failed because the control process exited with error code.
See "systemctl status caddy.service" and "journalctl -xe" for details.

5. What I already tried:

I don’t know what is wrong, so not sure what to try

6. Links to relevant resources:

N/A

Oh… I guess this is a parenthesis thing. Seems to work like this

sub1.mydomain.co.uk:80 {
        root * /var/www/html/sub1/webroot
        php_fastcgi unix//run/php-fpm/www.sock
        file_server
        log {
                output file /var/log/caddy/access.log
        }
}

sub2.mydomain.co.uk:80 {
     root * /var/www/html/sub2/spa
        php_fastcgi unix//run/php-fpm/www.sock
        file_server
        log {
                output file /var/log/caddy/access.log
        }   
}

Next time, please be specific about the exact version of Caddy you’re running. Run the caddy version command to find out.

Essentially we’re looking to know whether you’re running Caddy as a systemd service, via a docker image, as a windows service maybe, or even just directly with caddy run or caddy start.

But your mention of systemctl makes it obvious you’re running with systemd, so :+1:

But we don’t know whether you used our official systemd service file or a different one, which is prompted by this section:

Those are called “curly braces/brackets”:

But yeah – if you have more than one site, you need them all to define a block. As the docs explain here:

Always look at Caddy’s logs in journalctl, you’ll see the exact error message that Caddy emitted. See the docs on how to use Caddy when running as a systemd service, there’s the recommended command to use to read your logs:

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