We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install PHP 7.4 on Kali Linux

Learn how to – How To Install PHP 7.4 on Kali Linux.

So you are looking for a way to Install PHP 7.4 on Kali Linux rolling release?. PHP is a very popular server-side scripting language used in development of Web applications and creation of dynamic web pages. PHP applications usually work with HTML and interact with relation database management systems. This is why PHP is part of the LAMP or LEMP stack – Apache/Nginx, MySQL and PHP running on a Linux machine.

The GA release of PHP 7.4 was on November 28, 2019. Use the link to check all the new features of PHP 7.4. This setup has been done on Kali Linux 2020.x update.

How To Install PHP 7.4 on Kali Linux

Follow the steps below to install PHP 7.4 on Kali 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 Kali Linux.

Step 1: Update system

Ensure your system is updated:

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

Once the system is updated, proceed to add the SURY PHP repository.

Step 2: Add 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 repository.

echo "deb https://packages.sury.org/php/ bullseye 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. You’ll need to update the apt package index before installation.

sudo apt update

Then install  PHP 7.4 on Kali Linux.

sudo apt install php7.4

Fixing error ‘Depends: libffi7 (>= 3.3~20180313)

if you encounter the error message like below;

The following packages have unmet dependencies:
 php7.4-common : Depends: libffi7 (>= 3.3~20180313) but it is not installable

Download a newer release of Libffi7 package.

wget http://ftp.us.debian.org/debian/pool/main/libf/libffi/libffi7_3.3-6_amd64.deb

Install the package downloaded

$ sudo dpkg -i libffi7_3.3-6_amd64.deb
Selecting previously unselected package libffi7:amd64.
(Reading database ... 290731 files and directories currently installed.)
Preparing to unpack libffi7_3.3-6_amd64.deb ...
Unpacking libffi7:amd64 (3.3-6) ...
Setting up libffi7:amd64 (3.3-6) ...
Processing triggers for libc-bin (2.33-1) ...

Then try install PHP 7.4 on Kali Linux:

sudo apt install php7.4

Confirm PHP version installed.

$ php7.4 -v
PHP 7.4.27 (cli) (built: Dec 20 2021 21:30:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies

All additional PHP extensions can be installed with the command syntax:

sudo apt install php7.4-xxx

Example:

sudo apt-get install php7.4-{cli,json,imap,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

The installation of PHP on Kali Linux automatically configure Apache. If you want to use 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 install nginx php7.4-fpm

Then start and enable the services.

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

PHP FPM configuration files are located in the directory: /etc/php/7.4/fpm/. Default www pool configurations are in /etc/php/7.4/fpm/pool.d/www.conf can be checked with cat command and grep;

$ cat /etc/php/7.4/fpm/pool.d/www.conf | grep -v '^;'
[www]
user = www-data
group = www-data
listen = /run/php/php7.4-fpm.sock
listen.owner = www-data
listen.group = www-data

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

The 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

PHP Web Programming Video Courses:

PHP learn

You can begin your PHP applications development on Kali Linux. If you have a different Linux distribution, check out other guides available.

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

Cart

Your Cart is Empty

Back To Shop