Friday, December 27, 2024
Google search engine
HomeGuest BlogsHow To Install PHP 7.4 on Debian 10 / Debian 9

How To Install PHP 7.4 on Debian 10 / Debian 9

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

How can I install PHP 7.4 on Debian 10 (Buster) / Debian 9 (Stretch)?. PHP is the most widely used server-side scripting language in creation of dynamic web pages. PHP applications usually work well with HTML and interact with relation database management systems. With each release of PHP, there are plethora of new features.

This installation of PHP 7.4 on Debian 10 / Debian 9 is available for production use. The GA release was made public on November 28, 2019. It is not recommended to run beta release in Production. It should be used for testing new features in PHP 7.4 and preparation for deprecated features.

Install PHP 7.4 on Debian 10 / Debian 9

Follow the steps covered below to install PHP 7.4 on Debian 10 & Debian 9 Linux distribution. The latest builds of PHP for Debian are available on SURY PHP PPA repository. We’ll add the repository as prerequisite then install PHP 7.4 on Debian 10 / Debian 9 from it.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Step 1: Update system

Ensure your system is updated:

sudo apt update && sudo apt -y full-upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f

Step 2: Add SURY PHP PPA repository

Download and store PPA repository in a file on your Debian Server/Desktop. But first, download 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 repository.

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 / Debian 9

The last step is to Install PHP 7.4 on Debian 10 / Debian 9. Before installation, update system package list on added repositories.

sudo apt update

Then install  PHP 7.4 on Debian 10 / Debian 9:

sudo apt install php7.4

Answer yes when prompted to complete installation of PHP 7.4 on Debian 10 / Debian 9 Linux system.

Reading state information... Done
The following additional packages will be installed:
  apache2-bin libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libgdbm-compat4 libjansson4 liblua5.2-0 libpcre2-8-0 libperl5.28 libsodium23 perl
  php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline psmisc
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make libb-debug-perl liblocale-codes-perl
Recommended packages:
  apache2
The following NEW packages will be installed:
  apache2-bin libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libgdbm-compat4 libjansson4 liblua5.2-0 libperl5.28 libsodium23 perl php-common php7.4
  php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline psmisc
The following packages will be upgraded:
  libpcre2-8-0
1 upgraded, 21 newly installed, 0 to remove and 7 not upgraded.
Need to get 10.4 MB of archives.
After this operation, 53.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Use the next command to install additional packages:

sudo apt-get install php7.4-xxx

Example:

sudo apt-get install php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}

PHP configurations related to Apache is stored in /etc/php/7.4/apache2/php.ini

Step 4: Using PHP with Nginx Web Server

The installation of php on Debian configures Apache. For users interested in running Nginx and PHP, you need to stop and disable Apache service.

sudo systemctl disable --now apache2

Then install fpm extension 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/

The nginx and php-fpm services should be running.

$ 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 Thu 2019-09-19 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

Sep 19 17:32:26 deb10 systemd[1]: Starting The PHP 7.4 FastCGI Process Manager...
Sep 19 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 Thu 2019-09-19 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

Sep 19 17:32:27 deb10 systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 19 17:32:27 deb10 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Sep 19 17:32:27 deb10 systemd[1]: Started A high performance web server and a reverse proxy server.

Enjoy your websites and Web Applications development with PHP 7.4 on Debian 10 / Debian 9 Linux system.

For other Linux systems.

How To Install PHP 7.4 on CentOS 8 / RHEL 8

How To Install PHP 7.4 on Ubuntu

How To Install PHP 7.4 on CentOS 7

How To Install PHP 7.4 on Fedora

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments