Linux Mint

How to Install PHP 8 on Linux Mint 20?


Being a popular server-side scripting language, PHP is used in the creation of dynamic websites, content management systems, and many famous frameworks such as Laravel, WordPress, etc which are developed in PHP. As of preparing this post, the latest stable release of PHP is 8.2.

Installing PHP 8 on Linux Mint 20

PHP 8 is not included in the Linux Mint 20 standard repositories. However, it can be installed on Linux Mint 20 from the Ondřej Surý PPA repository.

Complete the below-given steps to install PHP 8 on Linux Mint 20:

Step 1: Update apt cache
Fire up the terminal and update the apt repository cache with the command:

$ sudo apt update

Step 2: Install dependencies
Next, install the required dependencies for PHP 8:

$ sudo apt install software-properties-common

The required dependencies are installed successfully.

Step 3: Add Ondřej PPA repository
Now, add the Ondřej Surý PPA repository with the command:

$ sudo add-apt-repository ppa:ondrej/php

Once the Ondřej Surý PPA repository is successfully added, update the apt repository cache again with the command:

$ sudo apt update

Step 4: Install PHP 8 on Linux Mint 20
Install PHP 8 on Linux Mint 20 with the command:

$ sudo apt install php8.0

The PHP 8 will be installed on Linux Mint 20.

Type the below-given command if you want to get PHP 8 as Apache Module:

$ sudo apt install php8.0 libapache2-mod-php8.0

Press ‘y’ to continue installing PHP 8 on Linux Mint 20.

Both above-mentioned commands will install PHP 8 on Linux Mint 20

Once the PHP 8 is successfully installed, check the installed version and verify the installation with the command:

$ php --version

The PHP 8.0.2 is installed on Linux Mint 20.

If you have installed PHP as an apache module, restart the apache server when the PHP is installed:

$ sudo systemctl restart apache2

Installing the PHP extensions on Linux Mint 20

The PHP extension enhances the functionality of PHP. Extensions are the PHP libraries and can be installed on Linux Mint 20 using the apt command as follows:

$ sudo apt install php8.0-<em>extension_name</em>

Have a look at the available PHP extensions with the command:

$ sudo apt-cache search php | grep php-

Let’s install the PHP MySQL extension with the command:

$ sudo apt install php8.0-mysql

The MySQL extension will be installed successfully.

Remove PHP 8 from Linux Mint 20

At any point, if you wish to remove PHP 8 from Linux Mint, run the below-given command to do so:

$ sudo apt remove --autoremove php8.0

Press ‘y’ to continue removing PHP 8.

Conclusion

A lot of programmers use PHP for creating websites. Installing PHP 8 on Linux Mint 20 is easy and straightforward. PHP 8 is available from the Ondřej Surý repository. This article explains PHP 8 installation on Linux Mint 20.

About the author

Kamran Sattar Awaisi

Kamran Sattar Awaisi

I am a software engineer and a research scholar. I like to write article and make tutorial on various IT topics including Python, Cloud Computing, Fog Computing and Deep Learning. I love to use Linux based operating systems.