sammlinux sammlinux
  • Ubuntu
    UbuntuShow More
    How To Install and Use Docker CE on Ubuntu 22.04
    26 Min Read
    How To Install and Secure phpMyAdmin on Ubuntu 22.04
    5 Min Read
    How To Secure SSH with Fail2Ban on Ubuntu 22.04
    8 Min Read
    How To Install Uptime Kuma on Ubuntu 22.04
    17 Min Read
    How To Install Ubuntu Server 22.04 LTS with Screenshots
    14 Min Read
  • Rocky Linux
    Rocky LinuxShow More
    How To Install phpMyAdmin on Rocky Linux 9
    15 Min Read
    How To Secure SSH with Fail2Ban on Rocky Linux 9
    12 Min Read
    How To Install Rocky Linux 9.2 Server with Screenshots
    12 Min Read
    How To Set Up a Firewall Using FirewallD on Rocky Linux 9
    8 Min Read
    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide
    10 Min Read
  • Debian
    DebianShow More
    How To Secure SSH with Fail2Ban on Debian 11
    8 Min Read
    How To Install Debian 11 (Bullseye) Server with Pictures
    12 Min Read
    How To Install and Setup Node.js on Debian 11
    6 Min Read
    How To Install PHP 8.2 on Debian 11
    12 Min Read
    How To Install Nginx on Debian 11: A Comprehensive Guide
    9 Min Read
  • Linux
    LinuxShow More
    Best Practices Linux Server Security for System Administrator
    8 Min Read
    A Simple Guide: How To Manage Groups on Linux
    5 Min Read
    How To Manage Log Files Using Logrotate In Linux
    7 Min Read
    The Easy Ways to Check File Size in Linux
    7 Min Read
    How To Backup Files From Remote Linux VPS Using Rsync Script
    12 Min Read
  • CentOS
    CentOSShow More
    How To Secure SSH with Fail2Ban on CentOS 7
    9 Min Read
    How To Install PHP 8.2 on CentOS 7 / RHEL 7
    18 Min Read
    How To Install Apache Web Server on CentOS 7
    11 Min Read
    How To Set Up a Firewall Using FirewallD on CentOS 7
    5 Min Read
    Initial Setup CentOS 7 Server: Secure and Efficient
    9 Min Read
  • DevOps
    DevOpsShow More
    How To Create AWS CloudFront: A Step-by-Step Guide
    10 Min Read
Reading: How To Install PHP 7.4 on Debian 11
Share
Font ResizerAa
Linux for BeginnersLinux for Beginners
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Search
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.

How To Install PHP 7.4 on Debian 11

Samuel Siahaan
By Samuel Siahaan
Last updated: September 8, 2023
SHARE

PHP (Hypertext Preprocessor) is a popular scripting language used for web development. It’s the backbone of many web applications and content management systems, such as WordPress and Joomla. In this tutorial, we will guide you through the process of how to install PHP 7.4 on Debian 11 system.

Contents
Table of ContentsWhy PHP 7.4?Key Features PHP 7.4PrerequisitesInstall PHP 7.4 on Debian 11Step 1: Update Your SystemStep 2: Add PHP 7.4 PPA RepositoryStep 3: Install PHP 7.4Step 4: Add Extensions for PHP 7.4Step 5: Configure PHP 7.4 Settings (Optional)Step 6: Using PHP 7.4 with Apache and NginxConfigure PHP 7.4 Application with ApacheConfigure PHP 7.4 Application with NginxStep 7: Test PHP 7.4 with a Web ServerStep 8: Secure Your PHP 7.4 InstallationConclusion

Table of Contents

  • Why PHP 7.4?
  • Key Features PHP 7.4
  • Prerequisites
  • Install PHP 7.4 on Debian 11
    • Step 1: Update Your System
    • Step 2: Add PHP 7.4 PPA Repository
    • Step 3: Install PHP 7.4
    • Step 4: Add Extensions for PHP 7.4
    • Step 5: Configure PHP 7.4 Settings (Optional)
    • Step 6: Using PHP 7.4 with Apache and Nginx
      • Configure PHP 7.4 Application with Apache
      • Configure PHP 7.4 Application with Nginx
    • Step 7: Test PHP 7.4 with a Web Server
    • Step 8: Secure Your PHP 7.4 Installation
  • Conclusion

Why PHP 7.4?

Basically PHP 7.4 is one of the most stable and widely used versions of PHP. It offers numerous improvements in performance, security, and language features. By installing PHP 7.4, you can ensure that your web applications run efficiently and securely.

Key Features PHP 7.4

PHP 7.4 is one of the intermediate versions in the PHP 7 series, which was a major milestone for the language. It introduced significant performance enhancements compared to PHP 5.x, along with a number of new features and improvements. Some of the key features and improvements introduced in PHP 7.4 include:

  • Typed Properties: PHP 7.4 introduced the ability to declare type hints for class properties. This improves code clarity and helps catch type-related errors during development.
  • Arrow Functions: Arrow functions provide a shorter syntax for defining anonymous functions, making code more concise and readable.
  • Covariant Returns and Contravariant Parameters: PHP 7.4 introduced better support for covariance and contravariance in method signatures, which helps with improving type flexibility and safety.
  • Preloading: This feature allows certain files to be preloaded into memory, resulting in improved performance by reducing the need to load and parse files on each request.
  • Shorter Syntax for Exceptions: PHP 7.4 introduced a shorter syntax for throwing exceptions, making error handling more streamlined.
  • Improved Error Messages: Error messages and warnings in PHP 7.4 are more descriptive and helpful, aiding developers in identifying and resolving issues more effectively.
  • Numeric Literal Separator: Developers can now use underscores to separate groups of digits in numeric literals, enhancing code readability for large numbers.
  • Weak References: PHP 7.4 introduced support for weak references, which allows developers to maintain references to objects without preventing them from being garbage-collected when they’re no longer needed.

To begin with, these are just a few highlights of the improvements and features introduced in PHP 7.4.Furthermore, as with any programming language, using the latest version ensures that you have access to the most up-to-date tools, performance enhancements, and security improvements. In addition, it grants you access to a larger ecosystem of packages and libraries developed by the community.

- Advertisement -

Prerequisites

Before we get started to install PHP 7.4 on Debian 11, make sure you have the following:

  • Debian 11 : Make sure you have a clean installation of Debian 11. To set this up, follow our guide Initial Setup Debian 11 Server: Secure and Efficient. You can deploy this on a physical machine or a virtual environment like VMware or VirtualBox.
  • A terminal window or SSH client for remote access.

Install PHP 7.4 on Debian 11

Here’s a simple guide on how to install and configure PHP 7.4 on your latest Debian 11 Servers. By following these steps, you can tap into the advantages it offers:

Step 1: Update Your System

Before install PHP 7.4 on Debian 11, it’s essential to update your system’s package list and upgrade installed packages to their latest versions. Open a terminal and run the following commands:

Bash
$ sudo apt update
$ sudo apt upgrade

Additionally, this ensures that your system is up to date with the latest security patches and package information.

Step 2: Add PHP 7.4 PPA Repository

We will use the Ondrej PPA for installing PHP on Debian 11 system, but first download GPG key. Enter the following command:

- Advertisement -
Bash
$ 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 Sury PHP PPA repository, use the following command to add this PPA.

Bash
$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Once the installation has been completed, an additional repository update is necessitated to ensure the implementation of the changes.

Bash
$ sudo apt-get update -y && sudo apt-get upgrade -y

Step 3: Install PHP 7.4

Afterwards you should be ready to proceed with the installation of PHP 7.4 on your Debian 11 Linux machine. Run the following command to install PHP 7.4 :

- Advertisement -
Bash
$ sudo apt install php7.4

When prompted, select “yes” to finalize the installation of PHP 7.4 on your Debian 11 Linux system.

Bash
Reading package lists... Done
Building dependency tree... Done
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 liblua5.3-0 libsodium23 php-common php7.4-cli php7.4-common php7.4-json
  php7.4-opcache php7.4-readline ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear
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 liblua5.3-0 libsodium23 php-common php7.4 php7.4-cli php7.4-common
  php7.4-json php7.4-opcache php7.4-readline ssl-cert
0 upgraded, 19 newly installed, 0 to remove and 2 not upgraded.
Need to get 6,429 kB of archives.
After this operation, 26.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

Once the setup is finished, you’ll have PHP 7.4 all set up and running on your server. You can achieve this by simply running the following command:

Bash
$ php -v
PHP 7.4.33 (cli) (built: Sep  4 2023 08:11:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

This command will display the PHP version and relevant information. Consequently, if you see PHP 7.4 listed, congratulations – you have successfully installed PHP 7.4 on your Debian 11!

Step 4: Add Extensions for PHP 7.4

Besides PHP itself, you might want to add some extra PHP features. To do that, you can use this command, but make sure to replace [module-name] with the package you want to add.

Bash
sudo apt-get install php7.4-<module-name>

You can also install multiple packages at the same time. You might want to consider installing the commonly needed modules based on these suggestions.

Bash
$ sudo apt install php7.4-{cli,fpm,common,zip,gd,mcrypt,mbstring,curl,xml,bcmath,json,ldap,fileinfo,tokenizer,opcache,apcu,pdo,mysql,mysqlnd,mysqli,pgsql,mongodb,redis,memcache,memcached,sockets,imagick,iconv,exif,simplexml,dom}

Here’s a brief explanation of some package:

  • php7.4: The core PHP package.
  • php7.4-cli: The PHP command-line interpreter.
  • php7.4-fpm: PHP FastCGI Process Manager.
  • php7.4-json: JSON support for PHP.
  • php7.4-common: Common files for PHP.
  • php7.4-mysql: MySQL database support for PHP.
  • php7.4-zip: ZIP archive support for PHP.
  • php7.4-gd: GD graphics library support for PHP.
  • php7.4-mbstring: Multibyte string support for PHP.
  • php7.4-curl: cURL support for PHP.
  • php7.4-xml: XML support for PHP.
  • php7.4-bcmath: BCMath arbitrary precision mathematics support for PHP.

You can customize the extensions based on your project requirements.

You can see a complete list of active PHP modules by using this command:

Bash
$ php -m

Step 5: Configure PHP 7.4 Settings (Optional)

Now that PHP is installed, you may need to adjust some settings to fit your project needs. The PHP configuration files can be found in the /etc/php/7.4/ directory. You can modify the php.ini file using your favorite text editor. For example:

Bash
$ /etc/php/7.4/cli/php.ini

Feel free to personalize settings, such as memory limits, error reporting levels, and other parameters, in order to better align them with your application’s needs.

Step 6: Using PHP 7.4 with Apache and Nginx

We will explore configurations for both Apache and Nginx web servers to host your PHP application.

Configure PHP 7.4 Application with Apache

In Apache, we can use a built-in module called mod_php to handle PHP code directly within the Apache process.

But before you go any further, make sure you’ve installed the Apache web server package along with PHP and the Apache PHP module.

Bash
$ sudo apt install apache2 libapache2-mod-php7.4

Enable mod_php module:

Bash
$ sudo a2enmod php7.4

Then restart Apache web server after the configuration.

Bash
$  sudo systemctl restart apache2

Configure PHP 7.4 Application with Nginx

When using Nginx, PHP code is typically handled by a separate process called PHP-FPM (FastCGI Process Manager). PHP-FPM runs as a background process, ready to handle incoming PHP requests and process them in separate instances. In this configuration, Nginx’s job is to pass incoming requests to PHP-FPM, enabling the execution of PHP code.

Before you continue, make sure you’ve stop/ disable Apache service installed the Nginx web server.

Bash
$ sudo systemctl stop apache2
$ sudo systemctl disable --now apache2

After that, install the FPM extension and the Nginx packages.

Bash
$ sudo apt install nginx php7.4-fpm

Access your Nginx server configuration and add the following code inside the existing http block. By including this configuration, PHP requests will be efficiently directed to PHP-FPM for smooth execution:

Bash
$ sudo vi /etc/nginx/nginx.conf

Add the following lines to the file:

Nginx
server {
    listen 80;
    server_name example.com;
    root /var/www/myweb;
    index index.php index.html;

    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }
}

After that validate Nginx configuration is ok.

Bash
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Then restart Nginx web server after the configuration.

Bash
$ sudo systemctl restart nginx

Step 7: Test PHP 7.4 with a Web Server

When you’ve installed your chosen web server, go ahead and make a test PHP file in the main directory where your web server serves its files. For instance:

Bash
$ echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php

Then open this file using your web browser by going to http://your_server_ip/phpinfo.php. If the page shows PHP details, it means PHP 7.4 is functioning correctly with your selected web server.

Install PHP 7.4 on Debian
PHP 74 Info on Debian 11

Finally you should see a page displaying detailed information about your PHP installation.

Step 8: Secure Your PHP 7.4 Installation

At this point for security reasons. It’s a good practice to remove the info.php file or restrict its access once you’ve confirmed that PHP is working correctly. Leaving it accessible can expose sensitive information about your server’s PHP configuration.

Conclusion

Finally Congratulations! You’ve successfully install PHP 7.4 on Debian 11 server. PHP is now ready to power your web applications, websites, and more. Remember to keep your server and PHP installation up to date with the latest security patches for optimal performance and security.

Additionally, if you encounter any issues or have specific PHP-related tasks, refer to the PHP documentation and Debian documentation for more information and guidance. Happy coding!

Also Read Our Other Guides :

  • How To Install PHP 8.2 on Debian 11
  • How To Install PHP 7.4 on Ubuntu Server 22.04
  • How To Install PHP8.2 on Rocky Linux 9
  • How To Install MariaDB 10.6 on Debian 11 Server
  • How To Install MariaDB 10.9 on Debian 11 Server

As I have shown, now you have learned how to install PHP 7.4 on Debian 11.

TAGGED:DebianLampPHPPHP 7.4PHP-FPMProgramming Language

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How To Install MariaDB 10.9 on Debian 11 Server
Next Article How To Install Nginx on CentOS 7: A Comprehensive Guide
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

How To Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu
Install and Configure Docker Swarm Mode on Centos 7
CentOS
How To Install and Config Thumbor on Debian 10
Debian
How To Install MariaDB 10.6 on Debian 11 Server
Debian
How To Install MongoDB 6.0 on Debian 10 & 11
Debian

You Might Also Like

CentOS

How To Build NGINX from Source (Compile) on Centos7

14 Min Read
Ubuntu

How To Install Composer in Ubuntu 22.04: A Comprehensive Guide

10 Min Read
Debian

How To Install Apache Solr 9.1 on Debian 11

9 Min Read
Rocky Linux

How To Build NGINX from Source (Compile) on Rocky Linux 9

14 Min Read
Debian

How To Install Debian 12 (Bookworm) Server with Screenshots

13 Min Read
Ubuntu

How To Install Python 3.11 from Source on Ubuntu 22.04

10 Min Read
Rocky Linux

How To Install PHP 8.2 on Rocky Linux 9

9 Min Read
Debian

How To Set Up a Firewall with UFW on Debian 11

8 Min Read
Show More

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

sammlinux sammlinux

Providing beginner-friendly Linux tutorials and open-source guides to simplify your digital infrastructure.

www.sammlinux.com © 2026 | All Rights Reserved

Join Us!
Subscribe to our newsletter and never miss our latest news, podcasts etc.

Subscribe to our newsletter to get our newest articles instantly!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?