Secara default instalasi PHP pada sistem operasi Openhabian Raspberry Pi adalah PHP7.0. Apabila hendak mengupgrade versi ke PH7.3 atau PHP7.4 maka kita akan mendapatkan pesan error. Error ini disebabkan karena repository untuk PHP7.0 ke atas tidak terdaftar pada Openhabian. Untuk bisa mengupgrade versi PHP maka repositorynya harus diupgrade terlebih dahulu.
Berikut adalah cara untuk mengupgrade PHP ke versi PHP7.4 pada sistem operasi Openhabian Raspberry Pi. Pertama -tama adalah cek terlebih dahulu versi PHP7 yang ada saat ini:
#php -v
PHP 7.0.33-0+deb9u10 (cli) (built: Oct 6 2020 17:08:28) ( 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+deb9u10, Copyright (c) 1999-2017, by Zend Technologies
Seperti yang terlihat di atas, versi saat ini yang terinstall adala versi 7.0.33. Jika kita langsung upgrade ke versi 7.4 misalnya, maka akan muncul pesan error
#sudo apt install php7.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.3
E: Couldn't find any package by glob 'php7.4'
E: Couldn't find any package by regex 'php7.4'
Pesan error seperti di atas disebabkan karena Openhabian tidak bisa menemukan repository untuk php7.4. Untuk itu kita perlu menambahkan repository dengan terlebih dahulu menambahkan repository PGP key:
# wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Get:3 https://packages.sury.org/php stretch InRelease [6,772 B]
Ign:4 https://dl.bintray.com/openhab/apt-repo2 stable InRelease
Hit:5 https://repos.influxdata.com/debian buster InRelease
Hit:6 https://packages.grafana.com/oss/deb stable InRelease
Get:7 https://dl.bintray.com/openhab/apt-repo2 stable Release [6,051 B]
Hit:7 https://dl.bintray.com/openhab/apt-repo2 stable Release
Get:8 https://packages.sury.org/php stretch/main armhf Packages [270 kB]
Fetched 302 kB in 3s (80.8 kB/s)
Reading package lists... Done
Setelah itu tambahkan repository PHP
# echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php7.list
Lalu update index repository
# sudo apt-get update
Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Get:3 https://packages.sury.org/php stretch InRelease [6,772 B]
Ign:4 https://dl.bintray.com/openhab/apt-repo2 stable InRelease
Hit:5 https://repos.influxdata.com/debian buster InRelease
Hit:6 https://packages.grafana.com/oss/deb stable InRelease
Get:7 https://dl.bintray.com/openhab/apt-repo2 stable Release [6,051 B]
Hit:7 https://dl.bintray.com/openhab/apt-repo2 stable Release
Get:8 https://packages.sury.org/php stretch/main armhf Packages [270 kB]
Fetched 302 kB in 3s (80.8 kB/s)
Reading package lists... Done
Kemudian install PHP7.4
#sudo apt install php7.4
Get:1 https://packages.sury.org/php stretch/main armhf php7.4-common armhf 7.4.13-1+0~20201130.33+debian9~1.gbpd59941 [589 kB]
Get:2 https://packages.sury.org/php stretch/main armhf php7.4-json armhf 7.4.13-1+0~20201130.33+debian9~1.gbpd59941 [16.5 kB]
Get:3 https://packages.sury.org/php stretch/main armhf php7.4-opcache armhf 7.4.13-1+0~20201130.33+debian9~1.gbpd59941 [170 kB]
Get:4 https://packages.sury.org/php stretch/main armhf php7.4-readline armhf 7.4.13-1+0~20201130.33+debian9~1.gbpd59941 [10.8 kB]
Get:5 https://packages.sury.org/php stretch/main armhf php7.4-cli armhf 7.4.13-1+0~20201130.33+debian9~1.gbpd59941 [1,187 kB]
Get:6 https://packages.sury.org/php stretch/main armhf libapache2-mod-php7.4 armhf 7.4.13-1+0~20201130.33+debian9~1.gbpd59941 [1,139 kB]
Get:7 https://packages.sury.org/php stretch/main armhf php7.4 all 7.4.13-1+0~20201130.33+debian9~1.gbpd59941 [43.4 kB]
...
...
Creating config file /etc/php/7.4/cli/php.ini with new version
Setting up libapache2-mod-php7.4 (7.4.13-1+0~20201130.33+debian9~1.gbpd59941) ...
Creating config file /etc/php/7.4/apache2/php.ini with new version
libapache2-mod-php7.4: php7.0 module already enabled, not enabling PHP 7.4
Setting up php7.4 (7.4.13-1+0~20201130.33+debian9~1.gbpd59941) ...
Processing triggers for php7.4-cli (7.4.13-1+0~20201130.33+debian9~1.gbpd59941) ...
Processing triggers for libapache2-mod-php7.4 (7.4.13-1+0~20201130.33+debian9~1.gbpd59941) ...
Updating FireMotD available updates count ... 2020-12-16 16:38:06,999: FireMotD: Error: Template folder doesn't exist. Upgrading from an older version? Please run make again or run the install function "FireMotD -I -v".
Setelah sukses, cek versi PHP yang sudah terinstall
#php -v
PHP 7.4.13 (cli) (built: Nov 30 2020 20:40:50) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies
Dan jika kita menggunakan Apache, jangan lupa untuk menonaktifkan modul PHP7.0 dan mengaktifkan modul PHP7.4 unutuk apache
#sudo a2dismod php7.0
#sudo a2enmod php7.4
Selamat mencoba.
Leave a Reply