Fastcgi php7 blank content

I’m trying to get Caddy and PHP7 to work. (PHP7 seems to be the only one available on Ubuntu 16.04 LTS.)

But it simply won’t work. Nothing is returned when trying to access a php page (e.x. a phpinfo page).

(Caddy itself works great. I tried a simple markdown page and it worked fine.)

I’ve checked and double-checked all the config files that I’m aware of.

This is my Caddyfile

photos.<domain> {
    root /var/www/photos.<domain>
    fastcgi / /var/run/php/php7.0-fpm.sock php
}

This is my /etc/php/7.0/fpm/pool.d/www.conf file

[www]
user = www-data
group = www-data
listen = /run/php/php7.0-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

Just some wild guesses.
Guess #1
Your caddyfile refences /var/run/php/php7.0-fpm.sock, but the php-fpm config has /run/php/php7.0-fpm.sock

On my Fedora machine /var/run symlinks to /run, but does Ubuntu also do this?

Guess #2
Does caddy run as www-data?

  1. It looks like both paths exist. I tried using /run instead of /var/run but the result was the same. Still completely blank.

  2. Yes, Caddy runs as www-data. I’m using the standard systemd file from the caddy install

Enable error log and check what error you are getting.

errors /path/to/error.log

Turns out the issue wasn’t with Caddy. php.ini was set not to show any errors and php-errors in the page caused it to return no result.

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