An in-place upgrade from Ubuntu 20.04 to 22.04 replaces PHP 7.4 with PHP 8.1. Your Nginx server blocks still pass PHP requests to /run/php/php7.4-fpm.sock, which no longer exists – so sites show 502 Bad Gateway, a blank page or “File not found”.
Step 1 – Install PHP 8.1-FPM and extensions
sudo apt updatensudo apt install php8.1-fpm php8.1-cli php8.1-mysql php8.1-mbstring php8.1-xml php8.1-curl php8.1-gd php8.1-zip php8.1-intl php8.1-bcmath php8.1-imagickCompare with what you used before (dpkg -l | grep php7.4) and install the 8.1 equivalents.
Step 2 – Point Nginx at the new socket
Find every reference to PHP 7.4:
grep -rn u0022php7.4u0022 /etc/nginx/Replace them in all site files at once (a backup of each file is kept with a .bak extension):
sudo sed -i.bak 's/php7.4-fpm.sock/php8.1-fpm.sock/g' /etc/nginx/sites-available/*.confStep 3 – Carry over PHP settings
Custom values such as upload_max_filesize or memory_limit were in /etc/php/7.4/fpm/. Copy them to /etc/php/8.1/fpm/php.ini (and any custom pool files in pool.d/).
Step 4 – Test and reload
sudo nginx -tnsudo systemctl restart php8.1-fpmnsudo systemctl reload nginxCheck WordPress compatibility
PHP 8.1 is stricter than 7.4. Update WordPress, themes and plugins before switching; check /var/log/nginx/error.log and the site’s debug log for deprecations. When everything works, remove PHP 7.4: sudo apt purge "php7.4*".
Setting up a new site instead? The Nginx Server Block Generator writes a complete config for any PHP version.

