Step by step guide to upgrade PHP version to PHP7.4 on ubuntu. You can upgrade your PHP version to latest release PHP7.4 on your ubuntu18.04 or Ubuntu 20.4.
This upgrade is tested on EC2 instance running Ubuntu 18.04 or Ubuntu 20.4 OS on AWS (Amazon Web Server). So the steps mentioned in this guide works on any cloud servers like AWS, DigitalOcean, Linode, Vultr or any VPS or Dedicated servers running Ubuntu 18.04 or Ubuntu 20.4.
Add PPA for PHP 7.4
Add the ondrej/php which has PHP 7.4 package and other required PHP extensions.
After this check php version using following command.
php -v
Enable PHP 7.4 for Apache
Now you need to tell apache to disable old module of PHP module (below I have mentioned step for PHP7.2, You need to replace it with your current PHP version) and enable the new php module using following command.
sudo a2dismod php7.2 sudo a2enmod php7.4
Restart Apache for the changes to take effect.
sudo service apache2 restart
Conclusion – It’s very easy and tested guide to upgrade your older PHP version to the PHP7.4. This guide may save your life in case your code require latest PHP version.
Try this and if you face any issue please mention in the comment. I will surely help you in this.