I update nginx to 1.4.7 and php to 5.5.12, After that I got the 502 error. Before I update everything works fine.
Just to add, on CentOS (and probably Red Hat and Fedora) the file to change the permissions to is at:
/etc/php-fpm.d/www.conf
After upgrading from Ubuntu 14.04 lts to Ubuntu 16.04 lts I found a yet another reason for this error that I haven't seen before.
During the upgrading process I had somehow lost my php5-fpm executable altogether. All the config files were intact and it took me a while to realize that service php5-fpm start
didn't really start a process, as it did not show any errors.
My moment of awakening was when I noticed that there were no socket file in /var/run/php5-fpm.sock
, as there should be, nor did netstat -an
show processes listening on the port that I tried as an alternative while trying to solve this problem. Since the file /usr/sbin/php5-fpm was also non-existing, I was finally on the right track.
In order to solve this problem I upgraded php from version 5.5 to 7.0. apt-get install php-fpm
did the trick as a side effect. After that and installing other necessary packages everything was back to normal.
This upgrading solution may have problems of its own, however. Since php has evolved quite a bit, it's possible that the software will break in unimaginable ways. So, even though I did go down that path, you may want to keep the version you're fond of just for a while longer.
Luckily, there seems to be a neat way for that, as described on The Customize Windows site:
add-apt-repository ppa:ondrej/php
apt-get purge php5-common
apt-get update
apt-get install php5.6
Neater solution as it might be, I didn't try that. I expect the next couple of days will tell me whether I should have.
I had a similar error after php update. PHP fixed a security bug where o
had rw
permission to the socket file.
/etc/php5/fpm/pool.d/www.conf
or /etc/php/7.0/fpm/pool.d/www.conf
, depending on your version. Uncomment all permission lines, like:
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
Restart fpm - sudo service php5-fpm restart
or sudo service php7.0-fpm restart
Note: if your webserver runs as user other than www-data, you will need to update the www.conf
file accordingly
In fact, "listen.mode" should be: "0660" and not "0666" as Other Writable or Other Readable is never a good choice here.
So try to find out as which user/group your webserver runs. I use CentOs and it runs as user "nginx" So add to your php-fpm.conf:
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
finally restart php-fpm
Consideration must also be given to your individual FPM pools, if any.
I couldn't figure out why none of these answers was working for me today. This had been a set-and-forget scenario for me, where I had forgotten that listen.user and listen.group were duplicated on a per-pool basis.
If you used pools for different user accounts like I did, where each user account owns their FPM processes and sockets, setting only the default listen.owner and listen.group configuration options to 'nginx' will simply not work. And obviously, letting 'nginx' own them all is not acceptable either.
For each pool, make sure that
listen.group = nginx
Otherwise, you can leave the pool's ownership and such alone.
In my case php-fpm wasn't running at all, so I just had to start the service