Tom Busby Tom Busby - 10 months ago 135
PHP Question

Docker php-fpm/nginx set-up: php-fpm throwing blank 500, no error logs

Git repo of project: (HEAD at time of writing is 823fd22).

Here is my docker-compose.yml:

image: nginx:stable
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- php
- php:php
- 80:80

image: php:5.6-fpm
- ./src:/var/www/html
- 9000

Into src/ I've created a fresh laravel project. This all functions correctly if I swap out index.php for one with a basic
echo "hello world";
and if I use
echo "called";exit();
I can identify that part of laravel's index.php does get executed.

It dies at line 53:

$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()

I have no idea why this happens, and I've tried using
docker exec -it <cid> bash
to have a look around my php-fpm container for error logs. All the logs are redirected to stderr/stdout (which is collected by docker).

Here is the output that docker collects:

php_1 | - 06/May/2016:12:09:34 +0000 "GET /index.php" 500
nginx_1 | - - [06/May/2016:12:09:34 +0000] "GET /index.php HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" "-"

As you can see "500" does pretty much nothing to help me work out why there was an error, but I can't find any way of getting the stack trace or anything like the proper error logs that apache's php extension would have produced.

Answer Source

As per our discussion in ##php on freenode...

Your issue is that the php.ini setting "log_errors" is set to Off.

your options are:

  • set log_errors=On in php.ini
  • set php_admin_flag[log_errors]=On in your pool config (for docker container based on php:5.6-fpm that is in the file /usr/local/etc/php-fpm.conf)
  • or possibly set log_errors=On in .user.ini (php's per-dir config, similar to .htaccess)