Nginx 无法与 uwsgi 通信(过早关闭连接)

Nginx 无法与 uwsgi 通信(过早关闭连接)

我的配置中缺少什么nginx/uwsgi/php-embed

rpm -qa|grep php

php-cli-5.4.16-36.el7_1.x86_64
php-xml-5.4.16-36.el7_1.x86_64
php-devel-5.4.16-36.el7_1.x86_64
php-common-5.4.16-36.el7_1.x86_64
php-5.4.16-36.el7_1.x86_64
php-xmlrpc-5.4.16-36.el7_1.x86_64
php-pdo-5.4.16-36.el7_1.x86_64
php-pgsql-5.4.16-36.el7_1.x86_64
php-embedded-5.4.16-36.el7_1.x86_64
uwsgi-plugin-php-2.0.11.1-1.el7.x86_64

/etc/nginx/conf.d/allbet.conf

server {
    listen 8081;
    # root /tmp;
    # index index.html index.htm;
    server_name 127.0.0.1;
    location /allbet {
        # uwsgi_pass unix:///run/uwsgi/allbet.sock;
        uwsgi_pass 127.0.0.1:9081;
        include uwsgi_params;
    }
}

/var/log/nginx/error.log

2015/08/31 15:35:25 [error] 114498#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /allbet/index.php HTTP/1.1", upstream: "uwsgi://127.0.0.1:9081", host: "127.0.0.1:8081"

/etc/uwsgi.ini

[uwsgi]
uid = uwsgi
gid = uwsgi
pidfile = /run/uwsgi/uwsgi.pid
emperor = /etc/uwsgi.d
stats = /run/uwsgi/stats.sock
emperor-tyrant = true
cap = setgid,setuid

/etc/uwsgi.d/allbet.ini

[uwsgi]
chmod-socket = 777
; maximum number of worker processes
processes = 4
; the user and group id of the process once it’s started
uid = mpapec
gid = mpapec
;socket = /run/uwsgi/%n.sock
socket = 127.0.0.1:9081
master = true
chdir = /home/mpapec/public_html/%n
; php
plugins = php
; jail our php environment
php-docroot = /home/mpapec/public_html/%n
php-index = index.php
; clear environment on exit
vacuum = true

/home/mpapec/public_html/allbet/index.php

<?php

print "pong\n";

更新

其中 centos7 包是uwsgiconfig.py需要额外配置的,

python uwsgiconfig.py --plugin plugins/php
# You can set the path of the php-config script with UWSGICONFIG_PHPPATH.
UWSGICONFIG_PHPPATH=/opt/php53/bin/php-config python uwsgiconfig.py --plugin plugins/php
# or directly specify the directory in which you have installed your php environment
UWSGICONFIG_PHPDIR=/opt/php53 python uwsgiconfig.py --plugin plugins/php

相关内容