Question

502 Bad Gateway error with php 8

Hi,

I followed the tutorial “How To Install Linux, Nginx, MySQL, PHP (LEMP stack) on Ubuntu 20.04” and now I have a 502 error when trying to use PHP. I looked at the error log and it says that its trying to connect to PHP 7, but I have PHP 8 installed. Is there a way to easily fix this?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi,

So I figured it out. In the /etc/nginx/sites-available/default file, you need to change

fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

to be

fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;

(or whatever PHP version that you are using)