Excellent software and practical tutorials
existcentos8Use dnf oryumThe command installed PHP andnginxThe initial installation went smoothly until I opened PHP when configuring nginx and it prompted a 502 Bad Gateway error!
After searching a lot on the Internet, all of them said that the 502 error was caused by insufficient cache in nginx.ini or other reasons. There was no reliable answer. The most important thing is that it was always nginx's problem!
There is no problem accessing the HTML of the web page, and the path settings are all normal! It's just that PHP cannot be accessed, and I wasted a lot of time debugging. Either it prompts a 502 error or it opens PHP and downloads.
It seems that it has nothing to do with PHP. In fact, the biggest problem lies in the PHP settings.
The PHP installed by dnf has very scattered directories. And many directory structures have changed!
I found the www.conf file and checked it. Port 9000 was not started at all!
Could it be that there is some security setting under centos8?
vi /etc/opt/remi/php74/php-fpm.d/www.conf
listen=/var/run/php-fpm/php-fpm.sock;
Change listen to listen = 127.0.0.1:9000, otherwise you cannot access php using 127.0.0.1:9000 in nginx.
Or change fastcgi_pass 127.0.0.1:9000; to listen=unix:/var/run/php-fpm/php-fpm.sock; in nginx.
After modifying www.conf, I restarted the PHP service. Everything is working fine now!
Popularize 502 Bad Gateway error for novices