Bon les #geeks et #sysadmin du coin, #Apache ou #nginx ? J’ai toujours utilisé Apache mais y parait que c’est recommandé de changer d’avis des fois si c’est justifié.

Well, I'm testing #caddy, but I can't get a site to work with PHP. If I put phpinfo(); in a file in /usr/share/caddy/, it works, but if I put it somewhere else, I get a ‘File not found’ error.
And I can access the static files on my test directory, the problem is only with the php files…
Any idea what I'm doing wrong?

Bon bah je teste #caddy, mais pas foutu d’avoir un site qui fonctionne avec PHP. Si je met un phpinfo(); dans un fichier dans /usr/share/caddy/, ça fonctionne, mais si je le met ailleurs j’ai un "File not found".
Et je peux accéder aux fichiers statiques sur mon répertoire de test, j’ai qu’un soucis avec les fichiers php…
Une idée de ce que je fais mal ?

#help #web #server #php

@faket

Does your caddy file define the "root" directory for your project?

eg. `root * /path/to/project/public`

p.s. I hope this article helps:

https://php.watch/articles/caddy-php

How to use Caddy Server with PHP

Caddy is a modular and fast web server platform written in Go. It supports PHP to serve requests with PHP-FPM, and this explains how to configure Caddy server with PHP-FPM.

PHP.Watch
@ghostwriter Yes it does.
I’ve just added on my message that I can access the static files on my directory, but not the .php files…

@faket

Since static files work, your root in Caddy is likely correct.

"File not found" is returning from "PHP FPM".

what does this command return for you?

`php -i | grep open_basedir`

@ghostwriter
> open_basedir => no value => no value

Is that bad ?

@faket that's good.

Since:

Static files work ✅
.php returns “File not found.” ❌
open_basedir is not set ✅
PHP works in /usr/share/caddy ✅

the remaining likely cause is most likely PHP-FPM chroot set to /usr/share/caddy

Run:

`grep chroot /etc/php/*/fpm/pool.d/*.conf`

If you see:

`chroot = /usr/share/caddy`

then PHP-FPM cannot see anything outside that directory.

Fix: `;chroot =`

then restart:

```
sudo systemctl restart php*-fpm
sudo systemctl reload caddy
```

@faket

If the above script can't find the PHP-FPM config location try running.

`php-fpm -i | grep "Loaded Configuration"`

@ghostwriter Meh, I already got chroot empty here :(

I moved some files (I’m testing with a privatebin) from my dir to /var/www dir, and some things are working and some aren’t, but here maybe the problem isn’t on caddy/php-fpm side.

@faket good luck, hope it works out.
@ghostwriter I got something working, thank you, even if I don’t really got what fixed my problems, and so if they’re really fixed.
https://paste.declosure.ch/
@ghostwriter Well, I got the problem.
My home dir right are 700, if I put it 755 I can run the PHP websites from inside my home dir. But I don’t understand why it can run static files then ^^'
@faket depending on the server, it might be serving the static files directly, while the php files need to be executed.

@faket have you tried FrankenPHP? It's still caddy, but built under the @thephpf

https://frankenphp.dev/

FrankenPHP: the modern PHP app server

FrankenPHP is a new app server for PHP apps (built on top of Caddy) and a library to embed the PHP interpreter in Go web servers.

@alessandrolai @thephpf Thank you for your message, I did see it, but I’m trying Caddy now :D
My PHP seems to be working, at least for my pastebin and my forgejo, I’ll see for the few php remaining websites.
@faket caddy
@fredix Iels font la promotion de Nano sur leur page d’accueil, c’est forcément des gens pas recommandables.
@faket lol
@fredix @faket toujours eu envie de tester #caddy pour le SSL automagique. Ou même #ferron
@frox @fredix Ah j’avoue c’est magique.
@faket caddy + uncloud = ❤@[email protected]
@fredix Par contre j’arrive pas à servir du PHP 😢
@faket faut utiliser php fpm
@fredix Wé, up and running, mais j’ai un "File not found. "…
@fredix Ah, si je fais pointer mon site sur /usr/share/caddy, alors j’ai pas de soucis.
@faket je peux pas t'aider j'utilise pas php
@fredix Wé, moi presque pas pour mes sites, mais des fois y en a besoin genre si je veux mettre une poubelle privée.
@faket au pire j'utilise docker
@fredix Nano, Docker, heureusement que j’ai pas mangé.