I wrote a script that fixes all your Nginx sites to php8 on Ubuntu 21.10

I had a working webserver running LEMP (Linux, Nginx, Mysql, PHP) and I saw my Linode Linux VPS had a release upgrade. So I ran the Ubuntu “do-release-upgrade” command and after 15 minutes of updating it was updated, hooray!

Except after rebooting, all my websites were dead with a 502 Nginx error.

Upgrading from Ubuntu 20 to Ubuntu 21.10 the Ubuntu gods forced the upgrade from PHP7.4 to PHP8.0.

I tried getting a phpinfo page to test if the php was processing, but instead nginx was just serving the php page like a download. So I knew it was a problem with the php being processed, Nginx has individual sites running through the sites-available and sites-enabled folder. I updated the sites-available files with the new php8.0 socket, assuming since they were already linked in sites-enabled then they should all work after the nginx service was restarted. However they still didn’t work, and after opening the linked files in the sites-enabled folder I realized those were just copied by the “sudo ln -s” command. So now for all my websites I need to change php7.4 socket to php8.0, delete all the sites-enabled links, then relink all the sites-available files. Doing this more than 2 times if pretty tedious. So naturally I wrote a script does all this, and for each of the sites in the sites-available folder it updates all of them and relinks them.

I’m working on cleaning up this script and releasing it to help others, might try releasing it on my github

Did you know only 1% of the internet is on php8? https://haydenjames.io/78-of-the-web-powered-by-php-1-on-php-8/

es_MXSpanish