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

$ 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

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

g. Install PHP 8.1 with all module or extensions

apt install php8.1-amqp php8.1-gd php8.1-mbstring php8.1-psr php8.1-uopz php8.1-apcu php8.1-gearman php8.1-mcrypt php8.1-raphf php8.1-uploadprogress
php8.1-ast php8.1-gmagick php8.1-memcache php8.1-readline php8.1-uui php8.1-bcmath php8.1-gmp php8.1-memcached php8.1-redis php8.1-vips
php8.1-bz2 php8.1-gnupg php8.1-mongodb php8.1-rrd php8.1-xdebug php8.1-cgi php8.1-grpc php8.1-msgpack php8.1-smbclient php8.1-xhprof
php8.1-cli php8.1-http php8.1-mysql php8.1-snmp php8.1-xml php8.1-common php8.1-igbinary php8.1-oauth php8.1-soap php8.1-xmlrpc
php8.1-curl php8.1-imagick php8.1-odbc php8.1-solr php8.1-xsl php8.1-dba php8.1-imap php8.1-opcache php8.1-sqlite3 php8.1-yac
php8.1-decimal php8.1-inotify php8.1-pcov php8.1-ssh2 php8.1-yaml php8.1-dev php8.1-interbase php8.1-pgsql php8.1-stomp php8.1-zip
php8.1-ds php8.1-intl php8.1-phpdbg php8.1-swoole php8.1-zmq php8.1-enchant php8.1-ldap php8.1-protobuf php8.1-sybase php8.1-zstd
php8.1-facedetect php8.1-mailparse php8.1-ps php8.1-tideways php8.1-fpm php8.1-maxminddb php8.1-pspell php8.1-tidy

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store