PHP-FPM Apache error_log

76 views
Skip to first unread message

cody

unread,
May 20, 2012, 10:34:09 PM5/20/12
to highload-php-en
Hello,

We have our PHP-FPM deployment up and running and everything is
working great, however the Apache error_log is lacking some big items
we need and I cannot find anyway to get that info. We would like to
see the REMOTE_IP in the logs, but I cannot find a way to do so...

FPM.conf:

php_admin_value[error_log] = /usr/local/apache/logs/error_log
php_admin_flag[log_errors] = on
php_admin_value[error_reporting] = E_ALL

Apache error_log:

Here is what I see when a PHP error happens... for some reason its
using UTC timezone as well.

[20-May-2012 21:09:05 UTC] foo bar

At minimum I would like to have REMOTE_IP passed to the log... any
ideas?

Thanks,
Cody

Sammie S. Taunton

unread,
May 21, 2012, 10:34:16 AM5/21/12
to highloa...@googlegroups.com
Hello,

Are you using the latest version of PHP-FPM? There are new access log options which allows you to set %R to get the Remote IP Address.

~ Sammie

cody

unread,
May 21, 2012, 11:46:32 AM5/21/12
to highload-php-en
Hi,

Yes, we are running php 5.3.13 with the --enable-fpm flag so I think I
am running the latest version.

I do see the %R for the access_log stuff, but does that same thing
work for error_log?

Thanks,
Cody

cody

unread,
May 21, 2012, 9:25:11 PM5/21/12
to highload-php-en
I have some more info...

I changed FPM from socket to 127.0.0.1:9000 and setup the access_log
to log %R

127.0.0.1 - 21/May/2012:21:20:50

So what I see is the connection is from the localhost address instead
of the actual remote IP. This is likely due to my apache config line:

FastCGIExternalServer /php -host 127.0.0.1:9000 -idle-timeout 1000

Is there a way to pass the remote_IP so it doesn't do this?

Thanks

Przemysław Pawliczuk

unread,
May 22, 2012, 7:34:32 AM5/22/12
to highloa...@googlegroups.com
I think you should replicate additional environment variable with real IP using SetEnv. It's likely normal that PHP shows IP address from asker.

cody

unread,
May 22, 2012, 12:45:49 PM5/22/12
to highload-php-en
I just don't get why it doesn't log the remote IP in the
error_log.... Apache logs it fine and the old php-cgi method we used
to use worked fine.

Is there a way I could tell PHP-FPM to use syslog or something so my
logs will show up correctly?

Using php-fpm my error_log looks like:

[22-May-2012 14:43:06 UTC] PHP Fatal error:


Using php-cgi my error_log looked like:

[Tue May 22 07:35:44 2012] [error] [client 206.246.88.54] PHP Warning:


Notice the PHP-FPM uses UTC timezone (I have EST set in my php.ini)...
any ideas on how I can make PHP-FPM log like everything used to?

It should just work because php $_SERVER['REMOTE_ADDR'] returns the
correct remote IP when you use that in a PHP-FPM script.

Thanks

On May 22, 7:34 am, Przemysław Pawliczuk <p.pawlic...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages