User Tools

Site Tools


php7_2_rpi3

This is an old revision of the document!


PHP7.2 with Nginx install for RPi3

1.0 --- RPi3 Preparation

Raspbian Updates

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade
sudo rpi-update
sudo reboot

Raspbian Configuration

sudo raspi-config

2.0 --- PHP7.2 install

Raspbian being based on Debian Stretch ships with PHP 7.0 by default. This works fine, but there is a new and better supported PHP 7.2 release available. To install this newer PHP version however, we must tap into the testing branch of Raspbian, commonly known by the codename buster. We must credit a new buster.list file used by Aptitude (apt-get):

sudo nano /etc/apt/sources.list.d/10-buster.list

Add this line:

deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi

Now, by adding this and referencing -t buster in our apt-get commands, it wil use the newer versions of files available in the buster release which is not considered 100% stable. To facilitate this we need to create a buster preferences file:

sudo nano /etc/apt/preferences.d/10-buster

And paste in the follwing:

Package: *
Pin: release n=stretch
Pin-Priority: 900

Package: *
Pin: release n=buster
Pin-Priority: 750

Save this file and update:

sudo apt-get update

Now you are ready to install PHP 7.2 from the buster release including all the common PHP packages:

sudo apt-get install -t buster php7.2 php7.2-common php7.2-curl php7.2-gd php7.2-fpm php7.2-cli php7.2-opcache php7.2-mbstring php7.2-xml php7.2-zip php7.2-mysql php7.2-imap php7.2-cgi php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php-memcache php-imagick php7.2-soap php7.2-json php7.2-readline

After this has been completed, you can quickly test to make sure things have been installed by simply typing:

php -v

You should see something like this:

PHP 7.2.9-1 (cli) (built: Aug 19 2018 06:56:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.9-1, Copyright (c) 1999-2018, by Zend Technologies
php7_2_rpi3.1548062507.txt.gz · Last modified: 2019/01/21 17:21 by pi