In this tutorial, we will show you how to upgrade PHP to version 7.4 on a web server with Nginx and php-fpm (based on Ubuntu or Debian Linux). PHP 7.4 contains a large number of updates to improve the stability, security, and performance of your web server and is highly recommended to use.
Add latest repositories and update package lists:
$ apt-add-repository ppa:ondrej/php
$ apt-add-repository ppa:ondrej/nginx
$ apt update
Install new PHP and PHP-FPM packages:
$ apt install -y php7.4 php7.4-cli php7.4-common php7.4-fpm
Check the installed PHP version:
$ php -v
PHP 7.4.22 (cli) (built: Oct 14 2021 13:07:59) (NTS)
Install additional libraries and modules for WordPress (optional):
$ apt install -y php7.4-mysql php7.4-mysqli php7.4-dom php7.4-simplexml php7.4-ssh2 php7.4-xml php7.4-xmlreader php7.4-curl php7.4-exif php7.4-ftp php7.4-gd php7.4-iconv php7.4-imagick php7.4-json php7.4-mbstring php7.4-posix php7.4-sockets php7.4-tokenize php7.4-pdo php7.4-sqlite3 php7.4-ctype php7.4-fileinfo php7.4-zip php7.4-exif
Modify the /etc/php/7.4/fpm/php.ini file. Uncomment the cgi.fix_pathinfo parameter and set it to 0.
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo=0
Restart the PHP-FPM service:
$ systemctl restart php7.4-fpm.service

Check that there is a new socket:
$ ls -1 /run/php/
php-fpm.sock
php7.2-fpm.pid
php7.2-fpm.sock
php7.4-fpm.pid
<strong>php7.4-fpm.sock</strong>
It remains to change the PHP-FPM version in the NGINX configuration file (specify a new socket):
$ nano /etc/nginx/sites-available/default
...
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
...
Check your NGINX configuration and if everything is OK, restart it.
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ systemctl reload nginx.service

I just went through this PHP upgrade process on my server and it wasn’t as painful as I expected! Though I did spend way too much time trying to get my ai video generator free tool working properly with the new version.
The TBC Talent Calculator lets you experiment with builds before logging in. ff326fa7.