Introduction:
Today, we are going to cover the Installation of PHP 7.4 on Debian 10 / 9 with Nginx Server Installation. PHP 7.4 comes with the more advanced features and improvements in order to help the Developers provide convenient way for developing web sites and writing different scripts. So, let’s start our Installation.
Installing PHP 7.4 on Debian 10 / 9
To Install PHP 7.4 on Debian you will be required to add a repository. The latest builds of PHP for Debian are available on SURY PHP PPA repository. Firstly we will add the repo and then move towards the Installation of PHP and Nginx.
Step 1: Update Your System
Simply run the below command to update & upgrade your system. After updating reboot your system.
sudo apt upgrade
sudo apt upgrade -y && sudo reboot
Step 2: Adding SURY PHP PPA Repository
Download the GPG key by running
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
Now, add a repository by typing
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
Step 3: Install PHP 7.4 on Debian 10 / 9
It’s time to install php 7.4 on your system. Don’t forget to update your packages before Installing php.
sudo apt update
Now, run the given command to Install php 7.4 on Debian
sudo apt -y install php7.4
Press Y when prompt to continue the process of Installing PHP 7.4 on Debian 10 / 9
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1
libcurl4 libgdbm-compat4 libgdbm6 libjansson4 libldap-2.4-2 libldap-common liblua5.2-0 libnghttp2-14 libpcre2-8-0 libperl5.28 librtmp1
libsasl2-2 libsasl2-modules libsasl2-modules-db libsodium23 libssh2-1 perl perl-modules-5.28 php-common php7.4-cli php7.4-common php7.4-json
php7.4-opcache php7.4-readline psmisc ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal
libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make
libb-debug-perl liblocale-codes-perl openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1
libcurl4 libgdbm-compat4 libgdbm6 libjansson4 libldap-2.4-2 libldap-common liblua5.2-0 libnghttp2-14 libperl5.28 librtmp1 libsasl2-2
libsasl2-modules libsasl2-modules-db libsodium23 libssh2-1 perl perl-modules-5.28 php-common php7.4 php7.4-cli php7.4-common php7.4-json
php7.4-opcache php7.4-readline psmisc ssl-cert
The following packages will be upgraded:
libpcre2-8-0
1 upgraded, 36 newly installed, 0 to remove and 7 not upgraded.
Need to get 15.0 MB of archives.
After this operation, 76.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Run the following command to Install additional packages with PHP 7.4 on Debian 10 / 9
sudo apt-get install php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}
Similarly you can follow the same syntax to install your other packages with php 7.4
sudo apt-get install php7.4-xxx
Step 4: Installing Nginx on Debian 10 / 9
As you know that you will be required to Install a web server in order to gain access for using and testing php on your system. By default web server is Apache but Nginx provide more convenience so I will recommend to use Nginx on your Debian system. Firstly, disable the Apache server by running
sudo systemctl disable --now apache2
Now, Install the fpm extensions and nginx packages.
sudo apt-get install nginx php7.4-fpm
PHP fpm Configuration files are located in the directory /etc/php/7.4/fpm/
Make sure that the services are running properly.
$ systemctl status php7.4-fpm nginx
● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-12-24 17:32:26 UTC; 14s ago
Docs: man:php-fpm7.4(8)
Main PID: 12151 (php-fpm7.4)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 2377)
Memory: 14.7M
CGroup: /system.slice/php7.4-fpm.service
├─12151 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
├─12152 php-fpm: pool www
└─12153 php-fpm: pool www
Dec 24 17:32:26 deb10 systemd[1]: Starting The PHP 7.4 FastCGI Process Manager…
Dec 24 17:32:26 deb10 systemd[1]: Started The PHP 7.4 FastCGI Process Manager.
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-12-24 17:32:27 UTC; 12s ago
Docs: man:nginx(8)
Main PID: 12362 (nginx)
Tasks: 2 (limit: 2377)
Memory: 3.2M
CGroup: /system.slice/nginx.service
├─12362 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─12363 nginx: worker process
Dec 24 17:32:27 deb10 systemd[1]: Starting A high performance web server and a reverse proxy server…
Dec 24 17:32:27 deb10 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Dec 24 17:32:27 deb10 systemd[1]: Started A high performance web server and a reverse proxy server.
You’ve all done. Enjoy developing your web applications and other projects with PHP 7.4 with greater and advanced functionalities on Debian system.