How to install PHP 7.1 on GNU/Linux Debian 8.7 (jessie) server?

Updated on September 2, 2017

This tutorial will explain how to install PHP and its dependent packages on GNU Linux. If the Linux is installed with minimal packages,  then you need to install packages such as add-apt-repository, apt-transport-https, ca-certificates etc., as these packages will be used to download the other packages during apt-get install.

Step 1: Install apt-transport-https and ca-certificates using apt-get

#apt-get install install apt-transport-https ca-certificates

Step 2: Find out the release info with the below command

#lsb_release -sc

If you don’t find the above command, then you need to install the package lsb-release

# apt-get install lsb-release

Step 3: Add PHP 7.1 repository

Based on your release info, add the repository which contains PHP 7.1 to the repository list. Append the below info to the already existing repository list in the file: /etc/apt/sources.list

# vim /etc/apt/sources.list
deb https://packages.sury.org/php/ <release_info> main
deb https://packages.sury.org/php/ <release_info> main

Example:

deb https://packages.sury.org/php/ jessie main
deb https://packages.sury.org/php/ jessie main

Step 4: Update apt database to include new packages

# apt-get update

Step 5: Install PHP 7.1 along with other necessary packages

# apt-get install php7.1 libapache2-mod-php7.1 php7.1-cgi php7.1-fpm php7.1-gd php7.1-mysql

Step 6: Verify the PHP installation using phpinfo() in index.php. Below is the snapshot

install PHP 7.1 on Debian 8.7 Linux

Was this article helpful?

Related Articles

Comments Leave a Comment

  1. Well this sounds like an awful idea, suggesting to install packages from an unknown repository onto anybodies machine. Thats how you let people hack your system, by installing untrustworthy binaries.

    Who owns sury.org? Are these packages legit? So, many, questions!

Leave a Comment