If your WordPress installation is running a version of PHP 5 and you need to upgrade it to PHP 7 (you might want to do this for security reasons, or so you can try out a new plugin), there are a few steps you may need to follow. These instructions are for Ubuntu 14.04.
Disclaimer: Please note that the steps required for your WordPress LAMP installation may vary, and these steps may not work for all installations. Backup your server before making any changes in case issues arise and follow these instructions at your own risk.
See if you can install PHP 7 (PHP 7.3 is what i’m using as the example for this article) using the following commands. You may need to follow these instructions first.
sudo apt-get update sudo apt-get install php7.3
Switch Apache2 over to PHP 7 and stop it from using PHP 5
Stop it from using PHP 5:
sudo a2dismod php5
Switch it to PHP 7:
sudo a2enmod php7.3
Ensure that the PHP MySQL extension is installed, otherwise you might get the following error: ‘Your PHP installation appears to be missing the MySQL extension which is required by WordPress.’
sudo apt-get install php7.3-mysql