Friday, July 27, 2018

Installing PHP7.2 on a Rapsberry Pi - janw.me

Installing PHP7.2 on a Rapsberry Pi

To get a big performance boost we will use PHP 7.1 instead of the older 5.6 which Rasbian still uses by default. But because this is the default we will need to do a few extra tweaks.
In the file /etc/apt/sources.list.d/10-buster.list add
deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi
After saving create the next file sudo nano /etc/apt/preferences.d/10-buster. With the content:
Package: *
Pin: release n=stretch
Pin-Priority: 900

Package: *
Pin: release n=buster
Pin-Priority: 750
Again save. Make the system aware of this source list with
sudo apt update
Now we are ready to install PHP7 with all it’s modules:
sudo apt-get install -y -t buster php7.2-fpm php7.2-curl php7.2-gd php7.2-intl php7.2-mbstring php7.2-mysql php7.2-imap php7.2-opcache php7.2-sqlite3 php7.2-xml php7.2-xmlrpc php7.2-zip php-apcu
When done check it with php -v it should show a PHP 7.2. (or higher).
Now we need to add a few fpm things for nginx to work properly.
sudo nano /etc/php/7.2/fpm/conf.d/90-pi-custom.ini
And add:
cgi.fix_pathinfo=0

upload_max_filesize=64m
post_max_size=64m
max_execution_time=600
Finally reload php
sudo service php7.2-fpm reload
Now PHP is ready to use

Extra

You might want image optimization.
We have installed php-gp for that. But that is not enough.
sudo apt install -y optipng gifsicle libjpeg-progs

No comments: