In this guide we will install php 7.4 and do very basic tweaks
Note: this post call also be used to install
php7.3, just change every reference to
php7.3 and higher are still supported
This guide should also work for installing
php8.0 but I haven’t tested this yet.
Check if you can install php7.4
To check if php7.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 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-intl 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 imagemagick php-imagick
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.
To check configuration run
php -i To see the phpinfo in the browser check the nginx guide, as php needs to be connected to nginx.
If you’re interested in installing some php applications you might want to follow these other guides. to install.