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

Tom Busby picture Tom Busby · May 6, 2016 · Viewed 12k times · Source

Git repo of project: https://github.com/tombusby/docker-laravel-experiments (HEAD at time of writing is 823fd22).

Here is my docker-compose.yml:

nginx:
  image: nginx:stable
  volumes:
    - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
  volumes_from:
    - php
  links:
    - php:php
  ports:
    - 80:80

php:
  image: php:5.6-fpm
  volumes:
    - ./src:/var/www/html
  expose:
    - 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   | 172.17.0.3 -  06/May/2016:12:09:34 +0000 "GET /index.php" 500
nginx_1 | 192.168.99.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

AcidReign picture AcidReign · May 6, 2016

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)