Php-fpm not showing errors from php exec function

execnginxPHP

I use PHP exec function to run some python scripts. I was using apache and it was logging all errors in error.log file. Whenever there was syntax error or anything, it was being logged in apache error log. But Now I have installed nginx and php-fpm.

The problem here is that whenever there is error in python, the nginx does not log anything in error.log. The $output passed as second argument in exec is also an empty array. So now there is no way I can get errors from python or terminal. Please show me the way to get those errors….

Best Answer

You can set your error log in your nginx site config file: nginx/sites/sites-available/{RELEVANT SITE FILE}.

Ensure you have this inside your file:

error_log  /var/www/logs/nginx.error.log debug_http;

You can also try using php's error reporting:

<?php

   error_reporting(E_ALL);
   ini_set('display_errors', '1');

   // Manual Error Log Creation
   error_log($customError, 3, "/var/www/logs/php.error.log");

   // YOUR CODE BELOW

?>

The other thing to look out for is if you're not outputting anything at all, then it can also show up as an error, check out this other stackoverflow post.