Note: this post call also be used to install
php7.3, just change every reference to
7.x. And skip right to “Actual install php“
Default Rasbian still ships with
php7.3, not that weird as at time of writing 7.4 is only released for about a month.
We will install the latest
php7.4. But because this is not the default we will need to do a few extra tweaks.
Add newer source
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 https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ 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.
cgi.fix_pathinfo=0 upload_max_filesize=64m post_max_size=64m max_execution_time=600
Finally reload php
sudo service php7.4-fpm reload
Now PHP is ready to use