Problem Nginx & php-fpm

641 views
Skip to first unread message

arteta

unread,
Aug 17, 2008, 6:50:10 PM8/17/08
to highload-php-en
I'm trying to secure access by a login / pass in nginx, so I put this:

location /postfixadmin/admin {
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/conf/htpasswd;
location ~ \.php$ {
fastcgi_pass unix:/dev/shm/php2.socket;
fastcgi_param SCRIPT_FILENAME /data/www/postfixadmin/admin
$fastcgi_script_name;}}

With a browser, called login / pass appears good, but after:

The page you are looking for is temporarily unavailable.
Please try again later.

# tail /usr/local/nginx/logs/error.log

2008/08/18 00:47:14 [error] 13923#0: *68 recv() failed (104:
Connection reset by peer) while reading response header from upstream,
client: 8.7.11.4, server: 21.3.20.6, request: "GET /postfixadmin/
admin/ HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php2.socket:",
host: "vigi.net"

2008/08/18 00:47:14 [error] 13923#0: *68 recv() failed (104:
Connection reset by peer) while reading response header from upstream,
client: 8.7.11.4, server: 21.3.20.6, request: "GET /postfixadmin/
admin/ HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php2.socket:",
host: "vigi.net"

####################

:/data/www/postfixadmin/admin# ls
backup.php create-domain.php edit-active-admin.php edit-
admin.php edit-mailbox.php list-domain.php viewlog.php
create-admin.php create-mailbox.php edit-active-domain.php edit-
alias.php index.php list-virtual.php
create-alias.php delete.php edit-active.php edit-
domain.php list-admin.php search.php

####################

log php-fpm 0.5.9-rc2 :

tail /usr/local/php/logs/php-fpm2.log

Aug 18 00:50:13.141784 [NOTICE] fpm_pctl_exec(), line 95: reloading:
execvp("/usr/local/php/bin/php-cgi", {"/usr/local/php/bin/php-cgi", "--
fpm", "--fpm-config", "/usr/local/php/etc/php-fpm2.conf"})
Aug 18 00:50:13.163849 [NOTICE] fpm_unix_init_main(), line 284:
getrlimit(nofile): max:8000, cur:8000
Aug 18 00:50:13.164043 [NOTICE] fpm_sockets_init_main(), line 363:
using inherited socket fd=6, "/dev/shm/php2.socket"
Aug 18 00:50:13.164220 [NOTICE] fpm_event_init_main(), line 88:
libevent: using epoll
Aug 18 00:50:13.164360 [NOTICE] fpm_init(), line 52: fpm is running,
pid 13985
Aug 18 00:50:13.165768 [NOTICE] fpm_children_make(), line 348: child
13986 (pool default) started
Aug 18 00:50:13.167694 [NOTICE] fpm_children_make(), line 348: child
13987 (pool default) started
Aug 18 00:50:13.167780 [NOTICE] fpm_event_loop(), line 105: libevent:
entering main loop
^[[15~Aug 18 00:50:32.444717 [NOTICE] fpm_got_signal(), line 48:
received SIGCHLD
Aug 18 00:50:32.444804 [WARNING] fpm_children_bury(), line 211: child
13986 (pool default) exited on signal 11 SIGSEGV after 19.279081
seconds from start
Aug 18 00:50:32.447210 [NOTICE] fpm_children_make(), line 348: child
13988 (pool default) started
Aug 18 00:50:34.717048 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 18 00:50:34.717110 [WARNING] fpm_children_bury(), line 211: child
13987 (pool default) exited on signal 11 SIGSEGV after 21.549440
seconds from start
Aug 18 00:50:34.718491 [NOTICE] fpm_children_make(), line 348: child
13989 (pool default) started
Aug 18 00:50:36.003134 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 18 00:50:36.003200 [WARNING] fpm_children_bury(), line 211: child
13988 (pool default) exited on signal 11 SIGSEGV after 3.556028
seconds from start
Aug 18 00:50:36.004464 [NOTICE] fpm_children_make(), line 348: child
13990 (pool default) started
Aug 18 00:52:47.088098 [NOTICE] fpm_children_make(), line 348: child
14018 (pool default) started
Aug 18 00:52:47.803207 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 18 00:52:47.803272 [WARNING] fpm_children_bury(), line 211: child
14016 (pool default) exited on signal 11 SIGSEGV after 21.951652
seconds from start
Aug 18 00:52:47.803802 [NOTICE] fpm_children_make(), line 348: child
14019 (pool default) started
Aug 18 00:52:48.617247 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 18 00:52:48.617309 [WARNING] fpm_children_bury(), line 211: child
14018 (pool default) exited on signal 11 SIGSEGV after 1.529233
seconds from start
Aug 18 00:52:48.617326 [WARNING] fpm_children_bury(), line 238: failed
processes threshold (10 in 60 sec) is reached, initiating reload
Aug 18 00:52:48.617341 [NOTICE] fpm_pctl(), line 256: switching to
'reloading' state
Aug 18 00:52:48.617389 [NOTICE] fpm_pctl_kill_all(), line 172: sending
signal 3 SIGQUIT to child 14019 (pool default)
Aug 18 00:52:48.617411 [NOTICE] fpm_pctl_kill_all(), line 181: 1 child
is still alive
Aug 18 00:52:48.619995 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 18 00:52:48.620066 [NOTICE] fpm_children_bury(), line 211: child
14019 (pool default) exited with code 0 after 0.816288 seconds from
start
Aug 18 00:52:48.620083 [NOTICE] fpm_pctl_exec(), line 95: reloading:
execvp("/usr/local/php/bin/php-cgi", {"/usr/local/php/bin/php-cgi", "--
fpm", "--fpm-config", "/usr/local/php/etc/php-fpm2.conf"})
Aug 18 00:52:48.641924 [NOTICE] fpm_unix_init_main(), line 284:
getrlimit(nofile): max:8000, cur:8000
Aug 18 00:52:48.642119 [NOTICE] fpm_sockets_init_main(), line 363:
using inherited socket fd=6, "/dev/shm/php2.socket"
Aug 18 00:52:48.642294 [NOTICE] fpm_event_init_main(), line 88:
libevent: using epoll
Aug 18 00:52:48.642432 [NOTICE] fpm_init(), line 52: fpm is running,
pid 14020
Aug 18 00:52:48.643723 [NOTICE] fpm_children_make(), line 348: child
14021 (pool default) started
Aug 18 00:52:48.645629 [NOTICE] fpm_children_make(), line 348: child
14022 (pool default) started
Aug 18 00:52:48.645717 [NOTICE] fpm_event_loop(), line 105: libevent:
entering main loop
Aug 18 00:52:49.774871 [NOTICE] fpm_got_signal(), line 48: received
SIGCHLD
Aug 18 00:52:49.774935 [WARNING] fpm_children_bury(), line 211: child
14021 (pool default) exited on signal 11 SIGSEGV after 1.131241
seconds from start
Aug 18 00:52:49.775784 [NOTICE] fpm_children_make(), line 348: child
14024 (pool default) started

A f5 Each of the page, I have the same message in php-fpm2.log.

I did not understand why this does not.

I also posted a request for nginx:
=> http://www.ruby-forum.com/topic/162914

Guillaume.

arteta

unread,
Aug 17, 2008, 10:15:18 PM8/17/08
to highload-php-en

Andrei Nigmatulin

unread,
Aug 17, 2008, 10:50:37 PM8/17/08
to highloa...@googlegroups.com
On Monday 18 August 2008 06:15, arteta wrote:
> I'm trying to secure access by a login / pass in nginx, so I put this:
>
> location /postfixadmin/admin {
> auth_basic "Restricted";
> auth_basic_user_file /usr/local/nginx/conf/htpasswd;
> location ~ \.php$ {
> fastcgi_pass unix:/dev/shm/php2.socket;
> fastcgi_param SCRIPT_FILENAME /data/www/postfixadmin/admin
> $fastcgi_script_name;}}

+ fastcgi_param REQUEST_METHOD $request_method;


This is a bug in php-fpm 0.5.9-rc2, will be fixed in next release.

--
Andrei Nigmatulin
GPG PUB KEY 6449830D

Now I lay me down to sleep(3)
Pray the OS my core to keep
If I die before I wake
Pray the Disk my core to take

mike

unread,
Aug 17, 2008, 10:48:52 PM8/17/08
to highloa...@googlegroups.com
Also you can define this globally

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

and not have to set the SCRIPT_FILENAME for each server/location block
with the hardcoded docroot location manually :)

arteta

unread,
Aug 17, 2008, 10:58:49 PM8/17/08
to highload-php-en
On 18 août, 04:50, Andrei Nigmatulin <andrei.nigmatu...@gmail.com>
wrote:
> This is a bug in php-fpm 0.5.9-rc2, will be fixed in next release.
Okay, thank you, I'll wait.

On 18 août, 04:48, mike <mike...@gmail.com> wrote:
> Also you can define this globally
>
> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>
> and not have to set the SCRIPT_FILENAME for each server/location block
> with the hardcoded docroot location manually :)
Same result with $document_root or no fastcgi_param.

Andrei Nigmatulin

unread,
Aug 17, 2008, 11:13:52 PM8/17/08
to highloa...@googlegroups.com
On Monday 18 August 2008 06:58, arteta wrote:
> On 18 août, 04:50, Andrei Nigmatulin <andrei.nigmatu...@gmail.com>
>
> wrote:
> > This is a bug in php-fpm 0.5.9-rc2, will be fixed in next release.
>
> Okay, thank you, I'll wait.

No need to wait ;-)

Have you tried adding "fastcgi_param REQUEST_METHOD $request_method;" ?


> On 18 août, 04:48, mike <mike...@gmail.com> wrote:
> > Also you can define this globally
> >
> > fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
> >
> > and not have to set the SCRIPT_FILENAME for each server/location block
> > with the hardcoded docroot location manually :)
>
> Same result with $document_root or no fastcgi_param.

--

mike

unread,
Aug 17, 2008, 11:10:20 PM8/17/08
to highloa...@googlegroups.com
On Sun, Aug 17, 2008 at 7:58 PM, arteta <Artet...@gmail.com> wrote:

>> Also you can define this globally
>>
>> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>>
>> and not have to set the SCRIPT_FILENAME for each server/location block
>> with the hardcoded docroot location manually :)

> Same result with $document_root or no fastcgi_param.

It won't change the behavior, it will just make configuration cleaner
and easier.

arteta

unread,
Aug 17, 2008, 11:54:30 PM8/17/08
to highload-php-en
> It won't change the behavior, it will just make configuration cleaner
> and easier.
Ba merci,

It works now, I understand nothing :)

I placed this:

http {
...
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root
$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi.conf;

server {
listen 80;
...

location /postfixadmin/admin {
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/conf/htpasswd;
location ~ \.php$ {
fastcgi_pass unix:/dev/shm/php2.socket;}}


and with the path "patch.inclusive" is ok.

Andrei, this is not a bug then?

Andrei Nigmatulin

unread,
Aug 18, 2008, 9:18:24 AM8/18/08
to highloa...@googlegroups.com

This is expected behavour.

The segmentation fault occured when fastcgi request have been formed without
REQUEST_METHOD parameter.

This is what you've got when you placed *only one* directive "fastcgi_param
SCRIPT_FILENAME" on location level.

Now you have moved the only fastcgi_param directive from location level to
http.

And from now *all* fastcgi_param directives from fastcgi.conf file are
inherited on the location level.

mike

unread,
Aug 18, 2008, 1:48:09 PM8/18/08
to highloa...@googlegroups.com
On 8/18/08, Andrei Nigmatulin <andrei.n...@gmail.com> wrote:

> Now you have moved the only fastcgi_param directive from location level to
> http.
>
> And from now *all* fastcgi_param directives from fastcgi.conf file are
> inherited on the location level.

This is the best, and can even include the SCRIPT_FILENAME. This is my
global fastcgi settings. I only need to change fastcgi_pass as needed.
Why create more configuration hassle right? :)

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_FILENAME $document_root$fastcgi_script_name;
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 $http_host;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_ignore_client_abort on;

Seems like so many people are reading nginx HOWTOs and it shows them
to define SCRIPT_FILENAME manually...

Reply all
Reply to author
Forward
0 new messages