Problems with php-fpm

Hey guys,

I am new to nginx an I am trying to set up nginx with php support
through php-fpm.
When I start php-fpm, it does spawn some php processes:

ps aux | grep php

root 30292 0.0 0.0 11852 2752 ? Ss Aug26 0:00
/usr/bin/php-cgi --fpm --fpm-config /etc/php5/php-fpm.conf
www-data 30296 0.0 0.0 11900 2460 ? S Aug26 0:00
/usr/bin/php-cgi --fpm --fpm-config /etc/php5/php-fpm.conf
www-data 30297 0.0 0.0 11900 2460 ? S Aug26 0:00
/usr/bin/php-cgi --fpm --fpm-config /etc/php5/php-fpm.conf

This seems about right, ain’t it?
I have configured nginx with the standart config, that comes with the
debian package (0.6.32). My fastcgi conf looks like this:
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}

cat /etc/nginx/fastcgi_params

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

PHP only, required if PHP was built with --enable-force-cgi-redirect

#fastcgi_param REDIRECT_STATUS 200;

Unfortunately I get an 50x error and the following is written to the
error.log:
2008/08/27 00:51:00 [error] 26403#0: *1 recv() failed (104: Connection
reset by peer) while reading response header from upstream, client:
xx.xx.xx.xx, server: localhost, request: “GET /index.php HTTP/1.1”,
upstream: “fastcgi://127.0.0.1:9000”, host: “xx.xx.xx.xx”

Searching the web I found out, that this error relates to
FCGI_WEB_SERVER_ADDRS not being set properly, but it is in my case:
127.0.0.1

php should also be listening on the right port:
127.0.0.1:9000

Does anybody have any hints for a nginx beginner?

Regards,
Samy

do you have a log from php-fpm?

also you can throw this in fastcgi_params, so you don’t have to define
it in each server block.

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

oh yeah - and fastcgi params can be included globally in http {} block
doesn’t need to be in each server/location block.

also i believe fastcgi_index can be removed completely.

those are just config cleanups - i don’t think it will help. from
looking at it quick it looks like you’ve got it setup right. can you
telnet to 127.0.0.1 9000 and get a response? i’d assume so, or it
would get connection refused…

Hey,

my php-fpm log looks like this:

tail /var/log/php-fpm.log

Aug 26 23:56:05.126603 [NOTICE] fpm_event_loop(), line 105: libevent:
entering main loop
Aug 26 23:56:06.316412 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 26 23:56:06.316518 [WARNING] fpm_children_bury(), line 211: child
30293 (pool default) exited on signal 11 SIGSEGV after 1.199164 seconds
from start
Aug 26 23:56:06.318898 [NOTICE] fpm_children_make(), line 348: child
30325 (pool default) started
Aug 27 00:50:51.454592 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 27 00:50:51.454705 [WARNING] fpm_children_bury(), line 211: child
30294 (pool default) exited on signal 11 SIGSEGV after 3286.335173
seconds from start
Aug 27 00:50:51.456926 [NOTICE] fpm_children_make(), line 348: child
26440 (pool default) started
Aug 27 00:51:00.613753 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 27 00:51:00.613874 [WARNING] fpm_children_bury(), line 211: child
30295 (pool default) exited on signal 11 SIGSEGV after 3295.492197
seconds from start
Aug 27 00:51:00.616219 [NOTICE] fpm_children_make(), line 348: child
26602 (pool default) started

I allready tried to telnet as well:

time telnet localhost 9000

Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
Connection closed by foreign host.

real 0m5.007s
user 0m0.001s
sys 0m0.004s

It always kicks me out after 5 seconds, which corresponds to:
5s
Don’t know if this relates to each other, but maybe it helps to debug my
problem!

Could there be something wrong with my self compiled php?
On the command line it works fine:

php-cgi

<?php echo "test"; ?>

X-Powered-By: PHP/5.2.6
Content-type: text/html

test

Thanks,
Samy

mike schrieb:

On Tue, Aug 26, 2008 at 05:24:11PM -0700, mike wrote:

also i believe fastcgi_index can be removed completely.
Yes, fastcgi_index is useless inside “~* .php$” location because a
request
with trailing slash i.e. “/some/dir/” and that requires the
fastcgi_index
directove, will never reach the location.

However, fastcgi_index may be set on http level, and will be inherited
in all locations.

On Wed, Aug 27, 2008 at 02:40:52AM +0200, Samuel Vogel wrote:

Hey,

my php-fpm log looks like this:

tail /var/log/php-fpm.log

Aug 26 23:56:05.126603 [NOTICE] fpm_event_loop(), line 105: libevent:
entering main loop
Aug 26 23:56:06.316412 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Aug 26 23:56:06.316518 [WARNING] fpm_children_bury(), line 211: child
30293 (pool default) exited on signal 11 SIGSEGV after 1.199164 seconds
from start

PHP processes exits abnormally on SIGSEGV signal.
Probably you need to add

fastcgi_param REQUEST_METHOD $request_method;

Look this:
http://groups.google.com/group/highload-php-en/browse_thread/thread/1148d4f859245b0a

Okay, I changed my configuration, but I am still getting the same error!

server {

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
}
}

http {

include fastcgi_params;
}

cat /etc/nginx/fastcgi_params

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

Do you guys have any other suggestions?
It seems like this problem is all about php-fpm so I should probably
post on their mailing list.

Regards,
Samy

On Wed, Aug 27, 2008 at 02:01:34PM +0200, Samuel Vogel wrote:

fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

Do you guys have any other suggestions?
It seems like this problem is all about php-fpm so I should probably
post on their mailing list.

Yes, this is php-fpm error and
http://groups.google.com/group/highload-php-en
is more relevant place to ask.

That all sounds like it’s properly functioning to me :frowning:

Maybe turn up your nginx error logging to debug, and/or see if PHP is
logging anywhere (turn error_reporting E_ALL) - on my machines it logs
to /var/log/user.log (as well as /var/log/syslog and /var/log/messages
I think) because I have error_log set to syslog in php.ini