I’m getting an error on my test server, but I can’t seem to activate debug mode to get details on the error.
(Disclaimer: I’m - obviously - absolutely and utterly clueless here. I’ve never worked with Kirby nor PHP before, I’m setting this up for someone else to maintain…)
Running the latest Kirby as a submodule on Ubuntu 20.04 behind nginx using php7.4-fpm.
What I think was happening is this: I tried visiting my.devserver.ip/, but got a 404 from nginx. Not knowing what I was doing, I tried my.devserver.ip/index.php, which got through to Kirby, but there’s not content for it, so Kirby renders a 404 page, which in PlainKit just says “Error”.
I still haven’t figured out how to turn on PHP error logging, but I noticed that php --ini gives me the .ini file for the php cli, not for fpm. The correct file on Ubuntu 20.04 is in /etc/php/7.4/fpm/php.ini.
Try setting debug mode in the config again, then create a deliberate PHP error, e.g. remove and endif statement or a semicolon… It should actually work because it enforces debug settings.
Can you be more verbose what the error looks like and what you did causing the error?
Your first config.php is missing the <?php statement, thats why you see the code on the page. Your second config.php should be ok or is there more in the file? If yes, please post the complete content of the file.
The default place for nginx log files is in /var/log/nginx/ and the files are named access.log and error.log. If your setup did not change these defaults, look into the files and post what you see at the time you get the error.
Ah, thanks so much for confirming that the <?php statement is required! I’m only now seeing that the first example on Configuration | Kirby includes it, but most subsequent examples and documentation omit it. E.g. here and here.
I’m still not seeing any errors in the nginx error.logs - not sure whats going on here. phpinfo() tells me:
error_log = syslog
log_errors = On
There’s nothing relevant in /var/log/syslog nor /var/log/nginx/error.log.
In the browser I now see a pretty error rendering by something called “Whoops”. Could that somehow catch errors and prevent them from being logged?
A <?php opening tag is required for all php code, otherwise it’s just regarded as text, so we don’t repeat it everywhere…
When you mix php with html, you also need a closing tag before you start with HTML, e.g
<?php foreach ( $page->images() as $image ) : ?> <!-- close PHP tag before we use HTML -->
<img src="<?= $image->url() ?>">
<?php endforeach; ?><-- Open PHP tag again to continue with PHP -->
The closing tag is omitted in PHP only files, like in the config.