How to Install PHP 8.1 | PHP 8.0 | PHP 7.4 | PHP 7.3 | PHP 7.2 | PHP 7.1 | PHP 7.0 | PHP 5.6 | PHP 5.5 | PHP 5.4 | PHP 5.3 on Ubuntu
Rate this post

Last Updated on July 24, 2023 by Vikash Ekka

PHP (PHP Hypertext Preprocessor). It is the one of the most popular scripting language for creating dynamic and interactive web pages. PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.). PHP is compatible with almost all servers used today (Apache, IIS, Nginx, etc.). PHP code is executed on the server.

In this tutorial post we are going to tell how to install all PHP version ( 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6, 5.5, 5.4) with all extension or modules on Ubuntu Operating System.

Prerequisites

  1. You must have sudo / root privileges to access Ubuntu Operating System
  2. Internet connection
  3. Operating System :- Ubuntu 22.04, 20.04, 18.04 LTS.

These commands can be also executed on Ubuntu 20.04 and 18.04 LTS.

Step 1. First Update and Install system packages:

To install any package on Ubuntu operating system need to update the repository’s package list by using the following command:

sudo apt update
sudo apt install software-properties-common

Step 2. Add PHP PPA Repository

Ondřej Surý, a Debian developer, maintains a repository that contains all PHP versions for the Ubuntu systems. To enable the repository , run the below command:

sudo add-apt-repository ppa:ondrej/php

Update the system packages

sudo apt update

Once the PPA is enabled, you can install any PHP version.

Installing PHP 8.1 on Ubuntu 22.04 LTS.

Before we move forward please make sure you have installed the php dependency packages. If you have not done yet then follow the above Steps. 1 and 2.

sudo apt install php8.1

Installing PHP 8.1 modules or extensions

Below I have mentioned all PHP 8.1 module that are generally needed for executing PHP code on the web server.

apt-get install php8.1-common php8.1-mysql php8.1-xml php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-tidy php8.1-yaml php8.1-bcmath -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v
php -m

Installing PHP 8.0 on Ubuntu 22.04 LTS.

Follow Steps. 1 and 2 for installing PHP dependency packages.

sudo apt install php8.0

Installing PHP 8.0 modules or extensions

Below I have mentioned all PHP 8.0 module that are generally needed for executing PHP code on the web server.

apt-get install php8.0-common php8.0-mysql php8.0-xml 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-tidy php8.0-yaml php8.0-bcmath -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v
php -m

Installing PHP 7.4 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php7.4

Installing PHP 7.4 modules or extensions

Below I have mentioned all PHP 7.4 module that are generally needed for executing PHP code on the web server.

apt-get install php7.4 php7.4-cli php7.4-cgi php7.4-gd php7.4-mysql php7.4-imap php7.4-curl php7.4-intl php7.4-pspell php7.4-sqlite3 php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-zip php7.4-mbstring php7.4-soap php7.4-opcache libonig5 php7.4-common php7.4-json php7.4-readline php7.4-xml -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v
php -m

Installing PHP 7.3 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php7.3

Installing PHP 7.3 modules or extensions

Below I have mentioned all PHP 7.3 module that are generally needed for executing PHP code on the web server.

apt-get install php7.3 php7.3-cli php7.3-cgi  php7.3-gd php7.3-mysql php7.3-imap php7.3-curl php7.3-intl php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl php7.3-zip php7.3-mbstring php7.3-soap php7.3-opcache php7.3-common php7.3-json php7.3-readline php7.3-xml -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v 
php -m

Installing PHP 7.2 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php7.2

Installing PHP 7.2 modules or extensions

Below I have mentioned all PHP 7.2 module that are generally needed for executing PHP code on the web server.

apt-get install php7.2 php7.2-cli php7.2-cgi  php7.2-gd php7.2-mysql php7.2-imap php7.2-curl php7.2-intl php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-zip php7.2-mbstring php7.2-soap php7.2-opcache php7.2-common php7.2-json php7.2-readline php7.2-xml -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v 
php -m

Installing PHP 7.1 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php7.1

Installing PHP 7.1 modules or extensions

Below I have mentioned all PHP 7.1 module that are generally needed for executing PHP code on the web server.

apt-get install php7.1 php7.1-cli php7.1-cgi  php7.1-gd php7.1-mysql php7.1-imap php7.1-curl php7.1-intl php7.1-pspell php7.1-recode php7.1-sqlite3 php7.1-tidy php7.1-xmlrpc php7.1-xsl php7.1-zip php7.1-mbstring php7.1-soap php7.1-opcache php7.1-common php7.1-json php7.1-readline php7.1-xml -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v 
php -m

Installing PHP 7.0 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php7.0

Installing PHP 7.0 modules or extensions

Below I have mentioned all PHP 7.0 module that are generally needed for executing PHP code on the web server.

apt-get install php7.0 php7.0-cli php7.0-cgi php7.0-gd php7.0-mysql php7.0-imap php7.0-curl php7.0-intl php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-zip php7.0-mbstring php7.0-soap php7.0-opcache php7.0-common php7.0-json php7.0-readline php7.0-xml -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v 
php -m

Installing PHP 5.6 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php5.6

Installing PHP 5.6 modules or extensions

Below I have mentioned all PHP 5.6 module that are generally needed for executing PHP code on the web server.

apt-get install php5.6-common php5.6-mysql php5.6-xml php5.6-curl php5.6-gd php5.6-imagick php5.6-cli php5.6-dev php5.6-imap php5.6-mbstring php5.6-opcache php5.6-soap php5.6-zip php5.6-tidy php5.6-yaml php5.6-bcmath -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v 
php -m

Installing PHP 5.5 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php5.5

Installing PHP 5.5 modules or extensions

Below I have mentioned all PHP 5.5 module that are generally needed for executing PHP code on the web server.

apt-get install php5.5-common php5.5-mysql php5.5-xml php5.5-curl php5.5-gd php5.5-imagick php5.5-cli php5.5-dev php5.5-imap php5.5-mbstring php5.5-opcache php5.5-soap php5.5-zip php5.5-tidy php5.5-yaml php5.5-bcmath -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v 
php -m

Installing PHP 5.4 on Ubuntu 22.04 LTS.

Follow Step. 1 and Step. 2 for installing PHP dependency packages.

sudo apt install php5.4

Installing PHP 5.4 modules or extensions

Below I have mentioned all PHP 5.4 module that are generally needed for executing PHP code on the web server.

apt-get install php5.4-common php5.4-mysql php5.4-xml php5.4-curl php5.4-gd php5.4-imagick php5.4-cli php5.4-dev php5.4-imap php5.4-mbstring php5.4-opcache php5.4-soap php5.4-zip php5.4-tidy php5.4-yaml php5.4-bcmath -y

Check PHP version and modules by following below command. php -m will list all PHP modules and extensions.

php -v 
php -m

Conclusion

In this articles, we have installed different PHP versions and modules on Ubuntu Operating System.

Let us know if you are facing any issue and difficulties while installing php in the below comment box, we will happy to assist you.

Happy Learning. !!!!

By Vikash Ekka

Hi All, My name is Vikash Ekka from India. I’m the founder and tech editor of https://www.vetechno.in. I have completed my Graduation in BCA. I love to write technical articles like Windows, Linux & MAC Tutorials, Tips, Tricks, How To fix, Tutorials About Ethical Hacking & Cyber Security Guide, and Software Review. Currently, I have been working as an IT professional since 2018.

One thought on “How to Install PHP 8.1 | PHP 8.0 | PHP 7.4 | PHP 7.3 | PHP 7.2 | PHP 7.1 | PHP 7.0 | PHP 5.6 | PHP 5.5 | PHP 5.4 | PHP 5.3 on Ubuntu 22.04 LTS”

Leave a Reply

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