Friday, March 19, 2021

How To Install PHP 7.4 on Debian 10 / Debian 9 | ComputingForGeeks

How To Install PHP 7.4 on Debian 10 / Debian 9 | ComputingForGeeks

🔥 Save unlimited web pages along with a full PDF snapshot of each page.
Unlock Premium →

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.

Step 1: Update system

Ensure your system is updated:

sudo apt update  sudo apt upgrade -y && sudo reboot

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 -y install php7.4

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

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

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

Using PHP with Nginx:

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.

PHP Learning courses:

The Complete Web Developer Course 2.0

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

Source: https://computingforgeeks.com/how-to-install-latest-php-on-debian/
This web page was saved on Thursday, Mar 18 2021.

Upgrade to Premium Plan

✔ Save unlimited bookmarks.

✔ Get a complete PDF copy of each web page

✔ Save PDFs, DOCX files, images and Excel sheets as email attachments.

✔ Get priority support and access to latest features.

Upgrade now →

No comments: