DebianLinuxTutorials

How To Install PHP 7.4 on Debian 10

Install PHP 7.4 on Debian 10

In this tutorial, we will show you how to install PHP 7.4 on Debian 10. In the ever-evolving landscape of web development, PHP remains a cornerstone technology, powering millions of websites and applications worldwide. With the release of PHP 7.4, developers can leverage improved performance, enhanced security features, and a wealth of new functionalities.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of PHP 7.4 on a Debian 10 (Buster).

Prerequisites

  • A server running one of the following operating systems: Debian 10 (Buster).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install PHP 7.4 on Debian 10 Buster

Step 1. To ensure a smooth installation process, it’s crucial to start with an updated Debian system. Open your terminal and execute the following commands to update the package lists and upgrade any existing packages:

sudo apt update
sudo apt upgrade

This step will fetch the latest package information from the Debian repositories and install any available updates, ensuring that your system is running the most recent versions of installed software.

Step 2. Installing PHP 7.4 on Debian 10.

First, install the necessary packages to enable the PPA:

sudo apt install lsb-release apt-transport-https ca-certificates

Next, import the GPG key for the SURY PHP PPA:

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

 Finally, add the SURY PHP PPA to your system’s sources list:

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

With the SURY PHP PPA added you can now proceed to install PHP 7.4 and its essential modules. Run the following command to install the PHP 7.4 package and commonly used extensions:

sudo apt update
sudo apt install php7.4 php7.4-fpm php7.4-mysql php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-zip

This command installs the PHP 7.4 package, along with several popular extensions:

  • php7.4-fpm: The FastCGI Process Manager for PHP, essential for running PHP applications with Apache or Nginx.
  • php7.4-mysql: Provides MySQL database integration for PHP.
  • php7.4-curl: Enables PHP to interact with various web servers and transfer data using the libcurl library.
  • php7.4-gd: Offers image processing capabilities, allowing PHP to create and manipulate images.
  • php7.4-mbstring: Provides multi-byte string support for handling Unicode-based data.
  • php7.4-xml: Enables XML parsing and manipulation within PHP scripts.
  • php7.4-zip: Adds support for reading and writing ZIP compressed archives.

Step 3. Test PHP.

To test PHP, create a test file named info.php with the content below. Save the file, then browse to it to see if PHP is working:

nano /var/www/html/info.php

Paste the following code:

<?php
phpinfo();
?>

Try to access it at http://your_server_ip/info.php. If the PHP info page is rendered in your browser then everything looks good and you are ready to proceed further.

Congratulations! You have successfully installed the PHP. Thanks for using this tutorial for installing PHP 7.4 on Debian 10 Buster system. For additional help or useful information, we recommend you check the official PHP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button