PHP7 logo

Installing PHP7.4 on a Rapsberry Pi

Note: this post call also be used to install php7.0, php7.1, php7.2 or php7.3, just change every reference to 7.x.
It should also work for php 8.0 but I will test that when php 8 is officially released.

Check if you can install php 7.4

To check if php 7.4 is available run: sudo apt install --dry-run php7.4
If you get an error continue, if you don’t get an error continue to actual install php

As the php version is not available
We are going to create a new source for php. We do this with the following 3 commands.

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
echo "deb buster main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

Actual install php

Now we are ready to install php7.4 with all modules we need:

sudo apt install -y php7.4-common php7.4-fpm php7.4-cli php7.4-curl php7.4-json php7.4-mysql php7.4-opcache php7.4-gd php7.4-sqlite3 php7.4-mbstring php7.4-zip php7.4-readline php-pear

When done check it with php -v it should show a php 7.4.0 or higher.
Now we need to add a few fpm things for nginx to work properly.
Create a extra config file sudo nano /etc/php/7.4/fpm/conf.d/90-pi-custom.ini.
And add:



Finally reload php

sudo service php7.4-fpm reload

Now PHP is ready to use


You might want to follow these instructions to install. wp-cli, composer, image compression support in php