4

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....

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You're right, but it does give you a general HTTP error log. I was just showing different ways to show various errors.
3

Nginx is not responsible for this kind of logging.

You must add error logging directives at your php-fpm.conf

2 Comments

Link leads to offline page now.
@rhand fixed this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.