1

My /etc/apt/sources.list file:

deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

I installed PHP 7.0 it with:

sudo apt-get install apache2 php7.0 php7.0-curl php7.0-gd php7.0-imap php7.0-json php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-xmlrpc libapache2-mod-php7.0

php -v output:

PHP 7.0.33-0+deb9u3 (cli) (built: Mar  8 2019 10:01:24) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33-0+deb9u3, Copyright (c) 1999-2017, by Zend Technologies

How can I update from 7.0 to 7.1?

1 Answers1

3

Unfortunately PHP 7.1 and greater does not exist in the official repositories of (Raspbian/Debian) Stretch. Therefore, you have to add further repositories to your sources list that contains packages for PHP 7.1 or greater.

A popular alternative repository for Debian based distributions is the Sury PHP Repository

How to add the repository

First add the repository's GPG Key:

curl -fsSL https://packages.sury.org/php/apt.gpg | sudo apt-key add -

After that you can add the repo to the source list:

echo "deb https://packages.sury.org/php/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/sury.list

Now you can update your source list and install the version you need e.g. PHP 7.3:

apt update
apt upgrade
apt install php7.3

As an alternative you could upgrade your system to the testing branch of Raspbian, but unless you really need packages from testing I would not recommend it.

flokoe
  • 321
  • 1
  • 4