php - Nginx 无法与 uwsgi 对话(连接过早关闭)

标签 php linux nginx centos 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";

最佳答案

/etc/nginx/conf.d/allbet.conf 文件中,您必须在 include uwsgi_params; 之后添加 uwsgi_modifier1 14;;.

这基本上指示 uWSGI 将请求路由到 PHP 插件。

关于php - Nginx 无法与 uwsgi 对话(连接过早关闭),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32318417/

相关文章:

php - 国家/地区的动态 PHP 下拉菜单

javascript - 向服务器发出的 HTTP 请求不更新标签

linux - 我应该将下载 tarball 放在哪里?

c++ - .so 大小会影响虚函数性能吗

ssl - nginx - 使用 ssl-support 设置多个 server_name

php - 坚持 laravel 插入

php - 如何在 laravel 4 中调试 ajax

linux - 如何从 'ps aux' 组的 'users' 输出中隐藏其他用户进程? Debian 挤压

caching - 禁用某些文件类型的 nginx 缓存

linux - 使用 mono 在 Centos 中部署 ASP.net