In terms of popularity and domination in server-side programming, PHP has made a name for itself. It is the go-to programming language for the development of dynamic and responsive web applications and CMS platforms like Magento, Drupal, and WordPress.
Therefore, if you wish to run such web-based applications or host CMS applications on your Ubuntu system, you must consider a proper PHP 8 installation guide.
Installing PHP 8 on Ubuntu Linux
For continued and improved performance of your Ubuntu system, make sure it is up-to-date.
$ sudo apt update && sudo apt upgrade -y
To install the latest PHP 8 version, you need to first remove the existing default PHP 7.4 installation from your Ubuntu 20.04 system by executing the following command.
$ sudo apt remove --purge php
![Remove PHP in Ubuntu](https://www.ubuntumint.com/wp-content/uploads/2022/03/Remove-PHP-in-Ubuntu.png)
Next, you need to add the Ondřej Surý PPA repository, which provides the latest installable PHP version for your Ubuntu system. Before adding this repository, install the following priority packages:
$ sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y $ sudo apt install -y language-pack-en-base $ sudo locale-gen en_US.UTF-8
Now add the Ondřej Surý PPA repository to your Ubuntu system:
$ sudo add-apt-repository ppa:ondrej/php
![Add Ondřej Surý PPA in Ubuntu](https://www.ubuntumint.com/wp-content/uploads/2022/03/Add-OndrejSury-PPA.png)
After adding a repository, once again, run a system update to gauge the preparedness of Ubuntu for the installation of PHP 8.
$ sudo apt update
Proceed to install PHP 8 via Ubuntu’s APT package manager.
$ sudo apt install php8.1
![Install PHP 8 in Ubuntu](https://www.ubuntumint.com/wp-content/uploads/2022/03/Install-PHP-in-Ubuntu.png)
Confirm the installed PHP version on your system.
$ php --version
![Check PHP in Ubuntu](https://www.ubuntumint.com/wp-content/uploads/2022/03/Check-PHP-in-Ubuntu.png)
Installing PHP 8 Extensions on Ubuntu 20.04
Your PHP projects will need the support of numerous PHP extensions to function normally. To install them, reference the following syntax:
$ sudo apt install php8.1-<extension>
For instance, popular PHP extensions like fpm, mysql, and soap can be installed in the following manner.
$ sudo apt install php8.1-{fpm,mysql,soap}
![Install PHP Extensions in Ubuntu](https://www.ubuntumint.com/wp-content/uploads/2022/03/Install-PHP-Extensions-in-Ubuntu.png)
Happy scripting as you explore what PHP 8.1 has to offer on your Ubuntu system projects.