Skip to content

How to Install PHP 8 on Ubuntu 20.04

How to Install PHP 8 on Ubuntu 20.04
What is PHP?

PHP is a server-side dynamic scripting language that is extensively used for web development. It is an open-source, cross-platform language that is free to use and runs on almost all operating systems including Windows, Linux, macOS, and Unix. In this tutorial, we’re going to learn How to Install PHP 8 on Ubuntu 20.04?

PHP 8 is the latest version & released in November 2020. It arrives with many unique features, modifications in performance, and security. Some of the major new features of PHP 8 including JIT (Just In Time) Compiler, Union Types, Named Arguments, Attributes.

PHP 8 requirements:

  • A running Ubuntu 22.04 system with root access
  • A basic understanding of the terminal and Linux commands
How do I install PHP 8 on Ubuntu 22.04 | 20.04 | 18.04?

Here’s a step-by-step guide to PHP 8 install Ubuntu 18.04 linux:

Step 1: Update your Ubuntu system:

Before we start, it’s a good idea to update the installed package list,

sudo apt update

if you face any difficulty installing and updating ubuntu visit this tutorial.

Step 2: Install PHP 8 on ubuntu linux

Now, we can install PHP 8(.1) in Ubuntu linux

sudo apt install php8.1 -y

this will install all required packages including PHP 8.1 package.

  • php8.1-cli – command line interpreter
  • php8.1-common – for documentation
Install PHP 8 on ubuntu linux

Step 3: Install PHP plugin(Optional)

php8.1-mysql – for working with MySQL databases

php8.1-curl – HTTP requests in PHP

php8.1-mbstring – non-ASCII strings

To install curl php 8 ubuntu, mysql, mbstring:

sudo apt install php8.1-mysql php8.1-curl -y

To install PHP 8 ubuntu nginx read here

Step 4: How to verify PHP installation in Ubuntu 22.04

Once the installation is complete, you can verify that PHP

php -v
verify php linux ubuntu

How to remove PHP in Ubuntu 22.04 linux?

To remove PHP in Ubuntu 22.04 including all configurations:

sudo apt purge php*

it’ll remove all your PHP packages, files, configaruoinsts

Note: If you want to remove its dependencies:

sudo apt-get autoremove
sudo apt autoremove ubuntu

The Short Note:

Congratulations! You have now installed PHP 8 on your Ubuntu 20.04 system. Let me know if you have any questions or encounter any issues during the installation process.

For reading PHP 8 documentation:

man php8.1

Thanks 🙂

Related blog: install apache on ubuntu 22.04

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *