Install PHP 5.6 | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 on Ubuntu

Here you will find how to install all PHP version module or extensions on Ubuntu System. Before we start make sure you have sudo privileges.

First update and install system packages:

$ sudo apt update -y
$ sudo apt install software-properties-common

Step 1: Add the Ondřej Surý PPA Repository

Ondřej Surý, a Debian developer, maintains a repository that includes multiple PHP versions. To enable the repository , run the below command:

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

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

a. Install PHP 5.6 with all module or extensions

apt-get install php5.6 php5.6-cli php5.6-cgi php5.6-gd php5.6-mysql php5.6-imap php5.6-curl php5.6-intl php5.6-pspell php5.6-recode php5.6-sqlite3 php5.6-tidy php5.6-xmlrpc php5.6-xsl php5.6-zip php5.6-mbstring php5.6-soap php5.6-opcache libicu65 php5.6-common php5.6-json php5.6-readline php5.6-xml php5.6-gettext apache2 php5.6 libapache2-mod-php5.6 -y

b. Install PHP 7.0 with all module or extensions

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

c. Install PHP 7.1 with all module or extensions

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

d. Install PHP 7.2 with all module or extensions

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

e. Install PHP 7.3 with all module or extensions

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

f. Install PHP 7.4 with all module or extensions

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

g. Install PHP 8.0 with all module or extensions

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

Im Youtuber