How To Install PHP (8.0, 7.3, 7.2 or 5.6) on Debian 9 VPS Print

  • php, 7.2, 7.3, 5.6, debian, vps, stretch, install, 8.0
  • 42

This tutorial is for the Debian 9 Stretch users to install PHP 8.0, 7.3, 7.2, 7.1 or 5.6 on their VPS.

First of all, you need to complete the prerequisites step and then go forward to install the PHP version of your choice or requirements.

Prerequisites

Login to your Debian 9 VPS using shell access. Connect with SSH. Windows users can use Putty or other alternatives applications for SSH connection.

ssh root@debian9

Run below commands to upgrade the current packages to the latest version.

sudo apt update 
sudo apt upgrade

Let’s execute the following commands to install the required packages first on your VPS system. Then import packages signing key. After that configure PPA for the PHP packages on your system.

sudo apt install ca-certificates apt-transport-https 
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

Now use one of the below options to install PHP of your requirements.

Installing PHP 5.6

Execute the following commands for installing PHP 5.6 on your Debian 9 Stretch VPS.

sudo apt update
sudo apt install php5.6

Also install required php modules.

sudo apt install php5.6-cli php5.6-common php5.6-curl php5.6-mbstring php5.6-mysql php5.6-xml

Installing PHP 8.0

Execute the following commands for installing PHP 5.6 on your Debian 9 Stretch VPS.

sudo apt update
sudo apt install php8.0

Also install required php modules.

sudo apt install php8.0-cli php8.0-common php8.0-curl php8.0-mbstring php8.0-mysql php8.0-xml

Available php modules/extensions can be listed as shown below:

$ sudo apt cache search php8.0-
php8.0-bcmath php8.0-curl-dbgsym php8.0-gmp-dbgsym php8.0-mysql php8.0-pspell-dbgsym php8.0-tidy
php8.0-bcmath-dbgsym php8.0-dba php8.0-imap php8.0-mysql-dbgsym php8.0-readline php8.0-tidy-dbgsym
php8.0-bz2 php8.0-dba-dbgsym php8.0-imap-dbgsym php8.0-odbc php8.0-readline-dbgsym php8.0-xdebug
php8.0-bz2-dbgsym php8.0-dev php8.0-interbase php8.0-odbc-dbgsym php8.0-snmp php8.0-xml
php8.0-cgi php8.0-enchant php8.0-interbase-dbgsym php8.0-opcache php8.0-snmp-dbgsym php8.0-xml-dbgsym
php8.0-cgi-dbgsym php8.0-enchant-dbgsym php8.0-intl php8.0-opcache-dbgsym php8.0-soap php8.0-xsl
php8.0-cli php8.0-fpm php8.0-intl-dbgsym php8.0-pgsql php8.0-soap-dbgsym php8.0-zip
php8.0-cli-dbgsym php8.0-fpm-dbgsym php8.0-ldap php8.0-pgsql-dbgsym php8.0-sqlite3 php8.0-zip-dbgsym
php8.0-common php8.0-gd php8.0-ldap-dbgsym php8.0-phpdbg php8.0-sqlite3-dbgsym
php8.0-common-dbgsym php8.0-gd-dbgsym php8.0-mbstring php8.0-phpdbg-dbgsym php8.0-sybase
php8.0-curl php8.0-gmp php8.0-mbstring-dbgsym php8.0-pspell php8.0-sybase-dbgsym

Installing PHP 7.3

You can also install the Latest PHP version on your VPS. Run the following commands to install PHP 7.3 on Debian 9.

sudo apt update
sudo apt install php7.3

Also install required php modules.

sudo apt install php7.3-cli php7.3-common php7.3-curl php7.3-mbstring php7.3-mysql php7.3-xml

Installing PHP 7.2

You can also install the Latest PHP version on your VPS. Run the following commands to install PHP 7.2 on Debian 9.

sudo apt update
sudo apt install php7.2

Also install required php modules.

sudo apt install php7.2-cli php7.2-common php7.2-curl php7.2-mbstring php7.2-mysql php7.2-xml

Installing PHP 7.1

If your application has the specific requirement of PHP 7.1, You can use the following commands for installing PHP 7.1 on Debian 9 Stretch VPS.

sudo apt update
sudo apt install php7.1

Also, install the required PHP modules as per your requirements. Here is a list of some frequently used modules.

sudo apt install php7.1-cli php7.1-common php7.1-curl php7.1-mbstring php7.1-mysql php7.1-xml

Was this answer helpful?

« Back