Prerequisites
Basic knowledge of using SSH Terminal on Linux.
Getting Started
Make sure your Ubuntu server is having the latest packages by running the following command.
sudo apt update
sudo apt upgrade
Add PPA for PHP 8.0
Add the ondrej/php
which has PHP 8.0 package and other required PHP extensions.
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Once you have added the PPA you can install PHP 8.0
Install PHP 8.0 & PHP Extensions
Installing PHP are simple with the following syntax.
sudo apt install php-8.0
Now, install some commonly used php-extensions
with the following command.
sudo apt install php8.0-common php8.0-mysql php8.0-xml php8.0-xmlrpc php8.0-curl php8.0-gd php8.0-imagick php8.0-cli php8.0-dev php8.0-imap php8.0-mbstring php8.0-opcache php8.0-soap php8.0-zip php8.0-redis php8.0-intl -y
Switch php versions
sudo update-alternatives --config php
should work for all ubuntu versions after 16.04 (18.04 and 20.04)
Choose the appropriate version
Conclusion
Now you have learned how to install PHP 8.0 on your Ubuntu 20.04 and also how to upgrade to latest version.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.