Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Nginx and PHP-FPM on Linux. I am not sure whether the issue is that PHP is not writing to the location specified in the PHP.ini, or if it just isn't working at all.

Some of the logs produced by Nginx and PHP-FPM contain the PHP errors, but they are mixed in with other Nginx log output. When I run phpInfo(), value in the error_log is set to a folder in my home directory, but nothing is ever created.

I understand that values in the Nginx conf and PHP-FPM conf can overwrite those set in the PHP.ini, but surely running phpInfo(), would show the final config values?

I would like to be able to have 1 folder, with seperate files for the Nginx access and error log as well as PHP errors.

Thanks.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

The error directory is pointing to your home directory, but I believe nginx don't have the access to write to your home directory, unless you are running nginx with your username.

If you want to write to some specific directory, it should have access to write to that directory.

Try to change the location of the error directory and it should work.

share|improve this answer
    
I changed the location to /etc/nginx/phperrorlog2.log but still no luck. Tried creating a blank file myself as well, but again, no luck. –  SteveEdson Dec 20 '12 at 11:33
    
which user you are running your nginx from? You can find the same with this command ps aux | grep nginx –  GeekRide Dec 20 '12 at 12:00
    
This shows the processes and their users gist.github.com/85cee085222eda5006ab –  SteveEdson Dec 20 '12 at 13:17
    
So, you are running nginx with nginx user. Now try checking the user for the /etc/nginx directory with this command ls -ld /etc/nginx. If it's not nginx then set it to nginx with this command chown -R nginx.nginx /etc/nginx. Then restart the process and it should work. –  GeekRide Dec 20 '12 at 13:34
    
Brilliant, that did the trick, thanks for the help. –  SteveEdson Dec 20 '12 at 14:08
show 2 more comments

Make sure log_errors is set to On. And make sure the error_log file is writable by the user PHP is running as. (usually www-data)

Nothing else to it, really.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.