Use PHP in caddy

Hello,
I’m trying to create a little and private web-api in PHP.
This is my Caddyfile:

...
    http://php.mysite.com, https://php.mysite.com {
           root /var/www/php
           gzip
    }
...

This is my test.php:

    <?php
    echo "Hello, world";
    ?>

When I do requests like php.mysite.com/test.php i receive the suorce code of test.php, not Hello, world.
Why this? How can I fix it? @matt

Resolved by doing:

...
    http://php.mysite.com, https://php.mysite.com {
           root /var/www/php
           gzip
           fastcgi / unix:/var/run/php/php7.0-fpm.sock {
               index index.php
           }
    }
...
1 Like

You should use the php preset… https://caddyserver.com/docs/fastcgi

3 Likes

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