Today I upgraded my localhost server from nginx 1.6.3 to 1.8.0 and now all my local websites are getting a 502 bad gateway.
A standard nginx config file is as follows
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;
}
}
The error message I'm getting is as follows
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"
The socket at /var/run/php5-fpm.sock exists so there is no problem there.
I found someone else with a problem on the same upgrade but their issue is different to mine and not getting any errors.
I tried adding this line to /etc/nginx/fastcgi_params but it does not alleviate the problem.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Alternatively is there a way to downgrade back to 1.6.2 or 1.6.3 and I can deal with this upgrade at a later date. I tried running
sudo apt-get install nginx=1.6.2-1+trusty0
But got the following error
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.