How to install PHP 7.4 on Kali Linux

Are you looking for a way to install PHP 7.4 on a Kali Linux rolling distro? PHP is a very popular server-side scripting language for developing web applications and creating dynamic web pages. PHP applications typically use HTML and interact with relational database management systems. That’s why PHP is part of the LAMP or LEMP stack-Apache / Nginx, MySQL and PHP running on Linux.

GA version of PHP 7.4 released November 28, 2019. Use the link to check all new features of PHP 7.4. This setup has been done in the Kali Linux 2020.x update. If you are running Kali Linux 2019.x, please check how to upgrade from Kali Linux 2019.x to 2020.x.

Install PHP 7.4 on Kali Linux

Follow these steps to install PHP 7.4 on a Kali Linux distribution. The latest version of Debian PHP is available in the SURY PHP PPA repository. We will add the repository as a prerequisite and then install PHP 7.4 on Kali Linux.

Step 1: Update the system

Make sure your system is updated:

sudo apt update
sudo apt upgrade -y

After the system is updated, continue to add the SURY PHP repository.

Step 2: Add the SURY PHP PPA repository

Import the GPG key and add the PPA repository.

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 the repository.

echo "deb https://packages.sury.org/php/ buster main" | sudo tee /etc/apt/sources.list.d/php.list

Step 3: Install PHP 7.4 on Kali Linux

The last step is to install PHP 7.4 on Kali Linux. Before installing, you need to update the apt package index.

sudo apt update

Then install PHP 7.4 on Kali Linux.

sudo apt -y install php7.4

Confirm that the PHP version is installed.

$ php -v
PHP 7.4.3 (cli) (built: Feb 20 2020 14:15:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

All other PHP extensions can be installed using the following command syntax:

sudo apt-get install php7.4-xxx

example:

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

Apache-related PHP configuration is stored in /etc/php/7.4/apache2/php.ini

Using PHP in Nginx:

Installing PHP on Kali Linux will automatically configure Apache. If you want to use Nginx and PHP, you need to stop and disable the Apache service.

sudo systemctl disable --now apache2

Then install the fpm extension and nginx packages.

sudo apt-get install nginx php7.4-fpm

Then start and enable the service.

sudo systemctl enable --now php7.4-fpm nginx

The PHP FPM configuration file is located in the directory: /etc/php/7.4/fpm/

Nginx and php-fpm services should be running.

$ systemctl status php7.4-fpm nginx
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: disabled)
     Active: active (running) since Sat 2020-02-22 09:48:42 EST; 13s ago
       Docs: man:php-fpm7.4(8)
   Main PID: 12645 (php-fpm7.4)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 2318)
     Memory: 15.2M
     CGroup: /system.slice/php7.4-fpm.service
             ├─12645 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
             ├─12646 php-fpm: pool www
             └─12647 php-fpm: pool www

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2020-02-22 09:48:42 EST; 13s ago
       Docs: man:nginx(8)
   Main PID: 12650 (nginx)
      Tasks: 9 (limit: 2318)
     Memory: 12.3M
     CGroup: /system.slice/nginx.service
             ├─12650 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ├─12652 nginx: worker process
             ├─12653 nginx: worker process
             ├─12654 nginx: worker process
             ├─12655 nginx: worker process
             ├─12656 nginx: worker process
             ├─12657 nginx: worker process
             ├─12658 nginx: worker process
             └─12659 nginx: worker process

You can start PHP application development on Kali Linux. If you use other Linux distributions, check out other available guides.

Install PHP 7.4 on Debian.

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

Sidebar