In this tutorial, I will show you how to install PHP 8 on your Ubuntu server.

Getting Started

Make sure your server is having the latest packages by running the command.

apt update && apt upgrade -y

Install the below packages

apt -y install lsb-release apt-transport-https ca-certificates wget

The latest PHP packages are available in the Ondřej Surý PPA repository.
Add the repository to your system.

add-apt-repository ppa:ondrej/php

Hit enter key when prompted to add the repository.

Install PHP 8

Next, update the system repositories to start using the PPA

apt install php8.0

 

Verify installation

php -v

I have apache installed on my server, so I can verify PHP 8 installation in PHP sample file.

echo "<?php phpinfo();" > /var/www/html/info.php

Now open in browser http:/your-IP/info.php

 

That’s all, you have successfully installed PHP 8 on your Ubuntu server.