今天我把我的本地主机服务器从nginx 1.6.3升级到了1.8.0,现在我所有的本地网站都得到了一个502坏的网关。
一个标准的nginxconfiguration文件如下
server { charset utf-8; client_max_body_size 128M; listen 80; ## listen for ipv4 server_name yii2.dive; root /media/Development/www/yii2/web; index index.php; access_log /media/Development/www/yii2/log/access.log combined; error_log /media/Development/www/yii2/log/error.log warn; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include fastcgi.conf; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; try_files $uri =404; } location ~ /\.(ht|svn|git) { deny all; } }
我收到的错误消息如下
2015/05/12 14:09:21 [error] 9295#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: yii2.dive, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "yii2.dive"
存在/var/run/php5-fpm.sock的套接字存在,所以没有问题。
我发现有人在同一个升级有问题,但他们的问题是不同的,我没有得到任何错误。
我试着把这一行join/ etc / nginx / fastcgi_params,但是并没有缓解这个问题。
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
另外还有一种方法可以降级到1.6.2或1.6.3,我可以在以后处理这个升级。 我试过跑步
sudo apt-get install nginx=1.6.2-1+trusty0
但是得到了以下错误
The following packages have unmet dependencies: nginx : Depends: nginx-full (< 1.6.2-1+trusty0.1~) but 1.8.0-1+trusty1 is to be installed or nginx-light (< 1.6.2-1+trusty0.1~) but it is not going to be installed or nginx-extras (< 1.6.2-1+trusty0.1~) but it is not going to be installed or nginx-naxsi (< 1.6.2-1+trusty0.1~) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
这对我有用
更换
include fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock;
同
include fastcgi.conf; fastcgi_pass 127.0.0.1:9000;
删除所有的nginx包:
aptitude purge nginx nginx-full
比添加官方的nginx deb repos:
deb http://nginx.org/packages/debian/ codename nginx deb-src http://nginx.org/packages/debian/ codename nginx wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key
最后安装nginx:
apt-get update apt-get install nginx
https://nginx.org/en/linux_packages.html
它应该现在工作。 如果没有,请参阅/var/log/nginx/error.log并修复错误。