I have a VPS since many years. Everything was working fine. The server was running PHP 7 and nginx.
Today the sites were running a bit slow. So I decided to login to the server and run a shutdown -r now
.
After reboot I have 502 Bad Gateway
in the browser and connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory)
in the nginx error.log.
I have no idea what could went wrong during this reboot. In journalctl
I don't see any error on boot.
Mysql is starting well.
php -v
PHP 7.2.22
nginx -v
nginx version: nginx/1.12.2
Here are some parts I have in the
vhosts:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
Maybe I was running on PHP5 and on reboot it updated to PHP7?? Would that be possible?
In yum history
the last install was in 2018.
ls -la |grep php
-rwxr-xr-x. 1 root root 4696240 Jul 20 2018 php
-rwxr-xr-x. 1 root root 4589728 Jul 20 2018 php-cgi
-rwxr-xr-x. 1 root root 4776 Jul 20 2018 phpize
This last says they are there since 2018, so I doubt a new php was installed after boot. Maybe the problem is somewhere else?
P.s. I do not have a sites-enabled/ folder. The vhosts are in the /etc/nginx/vhosts.d
folder.
I hope someone can help to troubleshoot and fix the issue
EDIT: I don't know if it
helps. I found out that in /var/run
I have only one folder php-fpm
which is empty. In my other 2 VPS with similar configuration (but are stil working) there are two items: php7-fpm.sock
and the folder php-fpm
which is not empty.
It's like PHP is not creating the sock there?
In /etc/php-fpm.conf
I have pid = /var/run/php-fpm/php-fpm.pid
In /etc/php-fpm.d/www.conf
I have listen = /var/run/php7-fpm.sock
EDIT2: I run service php-fpm restart
and now it created the socks. And it's working.
Final questions to answer this topic: I
restarted many times in the last years the server and it was always fine. Today after rebooting there was this problem. I rebooted once again and still the same problem. I had to manually restart php-fpm.
- Why I experienced this problem?
- What to do/check/fix in order to avoid this problem in future?
EDIT3: It was working few days. Today I decided to retry to reboot ubuntu.
After reboot, once again bad gateway.
[root@mysite ~]# ps faux|grep php
root 12149 0.0 0.0 112704 964 pts/0 S+ 11:33 0:00 \_ grep --color=auto php
Then I tried:
[root@mysite~]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
Once again:
[root@www01 ~]# ps faux|grep php
root 12152 0.0 0.0 112704 964 pts/0 S+ 11:37 0:00 \_ grep --color=auto php
Then I tried:
[root@mysite~]# service php-fpm restart
Redirecting to /bin/systemctl restart php-fpm.service
[root@mysite~]# ps faux|grep php
root 12176 0.0 0.0 112704 960 pts/0 S+ 11:38 0:00 \_ grep --color=auto php
root 12169 4.5 1.5 473028 16000 ? Ss 11:38 0:00 php-fpm: master process (/etc/php-fpm.conf)
nginx 12170 0.0 0.7 473028 7668 ? S 11:38 0:00 \_ php-fpm: pool www
nginx 12171 0.0 0.7 473028 7668 ? S 11:38 0:00 \_ php-fpm: pool www
nginx 12172 0.0 0.7 473028 7668 ? S 11:38 0:00 \_ php-fpm: pool www
nginx 12173 0.0 0.7 473028 7668 ? S 11:38 0:00 \_ php-fpm: pool www
nginx 12174 0.0 0.7 473028 7672 ? S 11:38 0:00 \_ php-fpm: pool www
But this time, even after service php-fpm restart
and running php process, I get bad gateway :(
In journalctl I see:
Feb 18 11:45:47 mysitepolkitd[658]: Registered Authentication Agent for unix-process:12210:153462 (system bus name :1.19 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Feb 18 11:45:47 mysite systemd[1]: Stopping The PHP FastCGI Process Manager...
Feb 18 11:45:47 mysite systemd[1]: Starting The PHP FastCGI Process Manager...
Feb 18 11:45:47 mysite systemd[1]: Started The PHP FastCGI Process Manager.
Feb 18 11:45:47 mysite polkitd[658]: Unregistered Authentication Agent for unix-process:12210:153462 (system bus name :1.19, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Any idea?