Nginx 1.6 + php5-fpm套接字通信失败

时间:2014-05-16 15:08:46

标签: sockets nginx

我有Nginx和PHP5-fpm的问题,如果我配置Nginx 1.2.1一切都很好,但如果我升级到1.6我只有空白页面。有人说为什么?

套接字创建正常。 Html页面正常工作 如果我在Chrome中看到网络,我有200OK 在PHP中只有:

<?php
phpinfo();
?>

我的confing文件:

/etc/nginx/conf.d/web.conf

server {

listen 192.168.99.127:8080;
server_name sub.localhost;


root /home/clients_ssl/sub/www;
index index.php index.html index.htm;

location ~ \.php$ {

fastcgi_pass unix:/etc/php5/fpm/socks/ssl_sub.sock;
include fastcgi_params;
fastcgi_param HTTPS on;

}

location ~ /\. {
deny all;
}

access_log /home/clients_ssl/sub/logs/access.log;
error_log /home/clients_ssl/sub/logs/error.log;
error_page 404 /404.html;

}

/etc/nginx/nginx.conf

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

/etc/php5/fpm/pool.d/web.conf

[ssl_sub]

listen = /etc/php5/fpm/socks/ssl_sub.sock
user = nginx
group = nginx
pm = dynamic
pm.max_children = 50
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 0
php_admin_value[open_basedir]=/
php_admin_value[session.save_path]=/home/clients_ssl/sub/tmp
php_admin_value[upload_tmp_dir]=/home/clients_ssl/sub/tmp
php_admin_value[disable_functions]=dl

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

(((如果我将lister.owner / group和user / group更改为其他系统用户,例如USER0我有错误502坏网关,哪里有问题?))))

的/ 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 HTTPS $https if_not_empty;

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;

2 个答案:

答案 0 :(得分:5)

如果您通过包含

升级了nginx
deb http://nginx.org/packages/debian/ wheezy nginx
deb-src http://nginx.org/packages/debian/ wheezy nginx

在/etc/apt/sources.list文件中,你的/ etc / nginx文件夹中没有fastcgi.conf的副本。

在/ etc / nginx中找到文件fastcgi_params并添加以下行:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

到文件的顶部。将文件重命名为fastcgi.conf

然后,您可以将。include fastcgi_params;替换为.conf文件的php位置块中的include fastcgi.conf;

答案 1 :(得分:2)

在更新nginx 1.2到1.6之后我也遇到了一些问题

我收到此信息(见下文),当我安装wheezy-backports main contrib non-free

我列出了这个列表: /etc/apt/sources.list

该来源:

deb http://ftp.de.debian.org/debian/ wheezy-backports main contrib non-free

安装信息:

  

Fastcgi配置问题============================

     

nginx发布了声明的修改后的fastcgi_params   SCRIPT_FILENAME fastcgi_param。此行已被删除。   从现在开始,我们也从上游发送fastcgi.conf   存储库,包含一个合理的SCRIPT_FILENAME参数值。

     

因此,如果您使用的是fastcgi_params,则可以尝试切换到   fastcgi.conf或手动设置相关的参数。

所以我在 etc / nginx / conf.d / default.conf中进行了更改

我将include fastcgi_params;更改为include fastcgi.conf;

location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
        fastcgi_read_timeout 600;
    }

然后,重新启动php5-fpm和nginx

我的php formular / form现在再次在nginx 1.6.2中运行