• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Debian » How To Install PHP 7.4 on Debian 11

How To Install PHP 7.4 on Debian 11

sammbysamm
October 17, 2023
install php74 on debian 11

How To Install PHP 7.4 on Debian 11

Share on FacebookShare on LinkedinShare on Whatsapp

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.

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.

OTHER POSTS

How To Secure SSH with Fail2Ban on Debian 11

How To Install Debian 11 (Bullseye) Server with Pictures

How To Install and Setup Node.js on Debian 11

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.

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:

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 :

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.

Tags: DebianLampPHPPHP 7.4PHP-FPMProgramming Language

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install MariaDB 10.9 on Debian 11 Server

Next Post

How To Install Nginx on CentOS 7: A Comprehensive Guide

Leave a Reply Cancel reply

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

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Secure SSH with Fail2Ban
Debian

How To Secure SSH with Fail2Ban on Debian 11

October 29, 2023
Install Debian 11 Server
Debian

How To Install Debian 11 (Bullseye) Server with Pictures

October 20, 2023
Install and Setup Node.js on Debian 11
Debian

How To Install and Setup Node.js on Debian 11

October 17, 2023
Install PHP 8.2 on Debian 11
Debian

How To Install PHP 8.2 on Debian 11

October 17, 2023
Load More
Next Post
Install Nginx on CentOS 7

How To Install Nginx on CentOS 7: A Comprehensive Guide

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.