~/nodetwelve.com$
34 notes · 6 topics
updated 2026-11-27

Updating PHP7-FPM on Ubuntu 20.04 for WordPress on nginx

· 1 min read

A short guide on how to install and configure PHP 7.4 FPM on Ubuntu 20.04, allowing your WordPress installation running on Nginx to use a newer, more secure PHP version.

The following instructions assume you already have Nginx and WordPress installed.

Installation of the required PHP packages

Open the terminal and run the following commands to install PHP 7.4 and the extensions required by WordPress.

apt install -y php7.4 php7.4-cli php7.4-common php7.4-fpm
apt install -y php7.4-mysql 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-tokenizer
apt install -y php7.4-mysqli php7.4-pdo  php7.4-sqlite3 php7.4-ctype php7.4-fileinfo php7.4-zip php7.4-exif

Edit the php.ini file

nano /etc/php/7.4/fpm/php.ini
cgi.fix_pathinfo = 0

Don't forget to save the changes and close the editor.

Update the nginx configuration

Open your Nginx site configuration file, replacing {your config files} with the actual configuration filename.

nano /etc/nginx/sites-available/{your config files}

Locate the fastcgi_pass directive and update the PHP-FPM socket path

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

This tells Nginx to pass PHP requests to the newly installed PHP 7.4 FPM service.

Restart PHP-FPM and Nginx

First, test the Nginx configuration to make sure there are no syntax errors. Then restart both services to apply the changes.

nginx -t
service nginx restart
service php7.4-fpm.service restart

That's it! Your WordPress installation should now be running through PHP 7.4 FPM instead of PHP 7.0.