Upgrading WordPress PHP 7.1 to PHP 7.2 to PHP 7.3 on Ubuntu 16.04 | 18.04 with Apache2

For those who don’t know, the latest version of WordPress ( 5.0.1 ) is built with support for the latest PHP 7.3… If you’re running older versions of PHP like 7.1 or 7.2, you can use the steps below to upgrade PHP to 7.3 with Apache2 HTTP server running WordPress CMS…

Although WordPress 5.0.1 support PHP 7.3, 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 compatible, continue below to learn how to upgrade your PHP version to support the latest version of WordPress…If you haven’t installed WordPress, search our website to learnh ow to install it on Ubuntu…

Upgrade PHP 7.1 to PHP 7.2 with Apache2 on Ubuntu

If you’re running PHP 7.1 and Apache2 on Ubuntu running WordPress, the steps below show you how to upgrade…

First, run the commands below to install PHP 7.2 packages

On some Ubuntu systems, PHP 7.2 may not be available in Ubuntu default repositories… To run PHP 7.2 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

sudo apt update

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

sudo apt install php7.2 libapache2-mod-php7.2 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, run the commands below to open PHP default configuration file for Apache2…

sudo nano /etc/php/7.2/apache2/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
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

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

sudo systemctl restart apache2.service

After that, run the commands below to enable PHP 7.2 support for Apache2….

sudo a2enmod php7.2

Then run the commands below to disable PHP 7.1

sudo a2dismod php7.1

After that, restart Apache2 HTTP server to use PHP 7.2…

sudo systemctl restart apache2.service

Finally, run the commands below to remove all PHP 7.1 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 should be enabled and PHP 7.1 completely removed from Ubuntu…

Upgrade PHP 7.2 to PHP 7.3 with Apache2 on Ubuntu

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

On some Ubuntu systems, PHP 7.3 may not be available in Ubuntu default repositories… To run PHP 7.3 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

sudo apt update

Next, run the commands below to install PHP 7.3 and related modules.

sudo apt install php7.3 libapache2-mod-php7.3 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, run the commands below to open PHP default configuration file for Apache2…

sudo nano /etc/php/7.3/apache2/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
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

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

sudo systemctl restart apache2.service

After that, run the commands below to enable PHP 7.3 support for Apache2….

sudo a2enmod php7.3

Then run the commands below to disable PHP 7.2

sudo a2dismod php7.2

After that, restart Apache2 HTTP server to use PHP 7.3…

sudo systemctl restart apache2.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 should be enabled and PHP 7.2 completely removed from Ubuntu…

That’s it!

You may also like the post below:

Install Lavalite CMS on Ubuntu 16.04 | 18.04 | 18.10 with Apache2, MariaDB and PHP 7.2

One Reply to “Upgrading WordPress PHP 7.1 to PHP 7.2 to PHP 7.3 on Ubuntu 16.04 | 18.04 with Apache2”

Leave a Reply to BRUCE W BENSON Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.