In this article, I will explain how you can upgrade your current PHP version on Ubuntu without losing any functionality.
First of all you have to add this PHP PPA repository.
You can check the repository you just added by listing this directory.
ls -lrt /etc/apt/sources.list.d
Once you have added the repository check the PHP version you are currently running with this command.
If for example you have PHP version 7.3 and you’d like to install PHP 7.4, then you should run this single command.
apt install $(apt list --installed | grep php7.3- | cut -d '/' -f1 | sed -e 's/7.3/7.4/g')
This command will automatically install all the required packages (the same ones as you had before) so that you don’t lose any package during the upgrade.
Once the new version is added, I recommend that you restart Apache.
service apache2 restart
And now you can check again your PHP version. It should be updated.
I hope this helped 🙂