11

I'm trying for about 4 hours to install PHP 7.4 on my Raspberry Pi Zero W.

I tried different tutorials, but I endup crashing my raspbian completly or just the installed php. With crashing I mean, I get the following message: Illegal instruction.

I also tried to install diffrent raspbians, but nothing worked till now.

Is it even possible to use PHP 7.4 on a raspberry pi?

Mr.Tr33
  • 229
  • 1
  • 2
  • 4

1 Answers1

20

First method:

You can install it manually by:

wget http://ftp.us.debian.org/debian/pool/main/p/php7.4/php7.4_7.4.1-1_all.deb 

And then:

dpkg -i php7.4_7.4.1-1_all.deb

It gives you a lot of dependencies which you must install before this package. It's the hardest method. Look at the second method which is much easier.


Second method:

Ensure your system is updated:

sudo apt update

Download and store the PPA repository in a file but first, download the GPG key:

sudo apt -y install lsb-release apt-transport-https ca-certificates

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Then add the repository:

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

The last step is to install PHP 7.4 on your Raspbian Buster. Before installation, update the system package list on added repositories:

sudo apt update

Then install PHP 7.4:

sudo apt -y install php7.4  

I just tested it and worked. I got the exact version by php -v:

PHP 7.4.2 (cli) (built: Feb  2 2020 07:53:49) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
M. Rostami
  • 4,323
  • 1
  • 17
  • 36
  • Comments are not for extended discussion; this conversation has been moved to chat. – goldilocks Feb 11 '20 at 16:48
  • resulted in Segmentation fault, can't autoremove it anymore :/ – clockw0rk Dec 28 '20 at 06:55
  • @clockw0rk Which method you've followed? – M. Rostami Dec 28 '20 at 07:29
  • 2
    The second one. Seems like there has changed a lot with php, wordpress and so on this year. switched to a different bloggin software now, since i could not even get nginx to install properly on raspian. they really should update the arm-package list – clockw0rk Dec 29 '20 at 02:00
  • You get my upvote. Followed method 2 in feb 2021 and got the expected results on raspberry os buster. It is always nice to see a good answer which explains each step. – Thomas Carlisle Feb 19 '21 at 17:17
  • Second method is perfect as of 13 April 2021, Linux raspberrypi 4.19.66-v7. PHP 7.4.16 (cli) (built: Mar 5 2021 08:37:59) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies – user3481644 Apr 13 '21 at 18:13
  • At a glance, that second method is going to require specific things of the shell you're using. If you're not familiar with how to translate it, bash works for certain. Edit: I take that back, it looks like the variable expansion works in most/all shells. – Steven Fisher May 21 '21 at 19:47
  • Works with Raspberry Pi OS 64 bit lite in October 2021! – smcs Oct 28 '21 at 09:24
  • Worked in April 2022 with Raspberry Pi 32-bit OS running on Pi 4. I also used some extra instructions from this post (for Apache-specific stuff): https://dev.to/samtarling/upgrading-apache-from-php-7-3-to-php-7-4-3a3h – nlawson Apr 16 '22 at 22:26