How can I find out why my php5-fpm failed to start?

I get 504 gateway timeout when I try to reach my server.

A small check didn't find any logs on php5-fpm logs, but just to make sure, I tried to restart it.

When I am trying to restart it:

sudo service php5-fpm restart

I get [fail], but when I do

sudo service php5-fpm stop
sudo service php5-fpm start

I get no error.

How can I investigate it if there are no logs? What can I do?


Solution 1:

Did you check your error_log file for php-fpm? Location of that file should be declared in your php-fpm.conf (in Ubuntu config is /etc/php5/fpm/php-fpm.conf, log file is /var/log/php5-fpm/log), also check your log_level, if is disabled (;log_level), please enable it and change it to the debug. After that try restart php5-fpm service and check your logs.

You can also try to run php5-fpm in foreground mode:

# php5-fpm -y /etc/php5/fpm/php-fpm.conf

Maybe this show you something interesting.

Solution 2:

Standard troubleshooting procedure:

  • Check the log file. If you don't know where it is check the config or to figure out for certain find the pid with ps aux | grep php-fpm, then do lsof -p $PID | grep log (omit the grep if it shows nothing).
  • 99% of the time log files will show you the cause. If not, look for a logging level in the config, raise it and try again.
  • Perhaps it quits instantly and you can't get the PID to inspect the process. You can also try starting the process in the foreground, but this means figuring out which commandline switches you need to use. Usually you just need to point it at your existing config.
  • If neither the log file or stdout/stderr (foreground output) contain include any clues it's time for strace... but that's another post.