Switch WordPress PHP 7.1-FPM to PHP 7.2-FPM to PHP 7.3-FPM with Nginx on Ubuntu 16.04 | 18.04

WordPress 5.0 and up comes with PHP 7.3-FPM support. If you’re running older versions of PHP-FPM, you can use the steps below to upgrade PHP to 7.3-FPM with Nginx HTTP server running WordPress CMS.

Although WordPress 5.0.1 support PHP 7.3-FPM, some themes and plugins may not. so you probably should make sure your themes and installed plugins support the latest PHP version, or you may run into issues.

If you have validated that all your plugins and themes are PHP 7.3-FPM compatible, continue below to learn how to upgrade your PHP-FPM versions to support the latest version of WordPress.If you haven’t installed WordPress, search our website to learn ow to install it on Ubuntu.

Upgrade PHP 7.1-FPM to PHP 7.2-FPM with Nginx on Ubuntu

If you’re running PHP 7.1-FPM and Nginx on Ubuntu running WordPress, the steps below show you how to upgrade to PHP 7.2-FPM.

First, run the commands below to install PHP 7.2-FPM packages

On some Ubuntu systems, PHP 7.2-FPM may not be available in Ubuntu default repositories… To run PHP 7.2-FPM on Ubuntu 16.04 and previous, you may need to run the commands below:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.2-FPM

sudo apt update

Next, run the commands below to install PHP 7.2-FPM and related modules.

sudo apt install php7.2-fpm php7.2-common php7.2-mysql php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-gd php7.2-xml php7.2-cli php7.2-zip

After installing PHP 7.2-FPM, run the commands below to open PHP default configuration file for Nginx…

sudo nano /etc/php/7.2/fpm/php.ini

The lines below is a good settings for most PHP based CMS… Update the configuration file with these and save….

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Everytime you make changes to PHP configuration file, you should also restart Nginx web server and PHP script… To do so, run the commands below:

sudo systemctl restart nginx.service
sudo systemctl restart php7.2-fpm.service

After that, run the commands below to enable PHP 7.2 support for Nginx. Open the Nginx site configuration file and configure the php block to use PHP 7.2-FPM.

Ubuntu default site configuration file can be found at

sudo nano /etc/nginx/sites-available/default

Then edit the php block session:

location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }

After that, restart Nginx HTTP server to use PHP 7.2-FPM.

sudo systemctl restart nginx.service

Finally, run the commands below to remove all PHP 7.1-FPM packages.

sudo apt-get purge `dpkg -l | grep php7.1| awk '{print $2}' |tr "\n" " "`

Doing that will prompt you to accept the changes to your system. then type Y to continue. When you’re done, PHP 7.2-FPM should be enabled and PHP 7.1-FPM completely removed from Ubuntu.

Upgrade PHP 7.2-FPM to PHP 7.3-FPM with Nginx on Ubuntu

Skip the above steps if you’re running PHP 7.2-FPM and you want to upgrade to PHP 7.3-FPM. First, run the commands below to install PHP 7.3-FPM packages

On some Ubuntu systems, PHP 7.3-FPM may not be available in Ubuntu default repositories… To run PHP 7.3-FPM on Ubuntu, you may need to run the commands below:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.3-FPM

sudo apt update

Next, run the commands below to install PHP 7.2-FPM and related modules.

sudo apt install php7.3-fpm php7.3-common php7.3-mysql php7.3-gmp php7.3-curl php7.3-intl php7.3-mbstring php7.3-xmlrpc php7.3-gd php7.3-xml php7.3-cli php7.3-zip

After installing PHP 7.3-FPM, run the commands below to open PHP default configuration file for Nginx…

sudo nano /etc/php/7.3/fpm/php.ini

The lines below is a good settings for most PHP based CMS… Update the configuration file with these and save….

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Everytime you make changes to PHP configuration file, you should also restart Nginx web server… To do so, run the commands below:

sudo systemctl restart nginx.service
sudo systemctl restart php7.3-fpm.service

After that, run the commands below to enable PHP 7.3-FPM support for Nginx. Open the Nginx site configuration and configure the php block to use PHP 7.3-FPM.

Ubuntu default site configuration file can be found at

sudo nano /etc/nginx/sites-available/default

Then edit the php block session:

location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }

After that, restart Nginx HTTP server to use PHP 7.2-FPM.

sudo systemctl restart nginx.service

Finally, run the commands below to remove all PHP 7.2 packages.

sudo apt-get purge `dpkg -l | grep php7.2| awk '{print $2}' |tr "\n" " "`

Doing that will prompt you to accept the changes to your system. then type Y to continue. When you’re done, PHP 7.3-FPM should be enabled and PHP 7.2-FPM completely removed from Ubuntu.

That’s it!

You may also like the post below: