أخر الاخبار

How to Install PHP 8 on Debian 10

How to Install PHP 8 on Debian 10


PHP is a scripting language and a powerful tool for developing dynamic and interactive web pages. It was originally created in 1994 by Danish-Canadian programmer Rasmus Lerdorf. According to data from W3Techs, PHP is used by 78.9% of websites running on the public network. So almost 8 out of 10 websites on the internet use PHP in some way.


PHP 8.0 is the latest version available for web development. This is the most advanced and secure version released by the PHP team.


This tutorial will help you install PHP 8.0 on Debain 10 Buster Linux system.


Step 1: Configure the Apt repository

Ondrej Sury maintains the PPA which contains the latest PHP packages for Debian systems.


Let's start by installing some required packages on your system. Open a terminal and run the following commands:


sudo apt update


sudo apt install -y gnupg2 ca-certificates apt-transport-https software-properties-common

Then add the GPG key to your system to verify the packages before installation.


wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -

Create a PPA file on your system with the php repository on your Buster Linux system.


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

Step 2: Install PHP 8 on Debian

Your system is ready for installing PHP. Use the following commands to install PHP 8 on the Debian system.


sudo apt update

sudo apt install php8.0

The first command will update the apt cache on your system and the second command will install the PHP packages.


Once the installation is complete, check the version of PHP on the terminal.


php -v




Step 3: Install PHP extensions

PHP comes with several extensions (also called modules) to perform specific tasks. You can install these extensions on your system as per your requirement.


First, search for available modules in the repository:


sudo apt search php8.0-*

Then install the required php modules on your system. The following command will install some frequently used PHP modules on your system.


sudo apt install php8.0-{mysql,imap,ldap,xml,curl,mbstring,zip}

You can check the currently installed and active PHP modules on your system by running the following command.


php -m

Step 4: Configure Apache with PHP

Generally, the above commands also install the Apache PHP extension on your system. But if it is not installed then run below command to install Apache with PHP 8 module.


sudo apt install apache2 libapache2-mod-php8.0

After successful installation, restart the Apache service to reload the newly installed modules.


sudo systemctl restart apache2

Next, check that the PHP modules are loaded with Apache. Create a php script with a phpinfo()function under the default document root.


echo "" > /var/www/html/info.php

Access this file in the browser using the server's IP address. For example: http://server-ip/info.php





You will see the detailed PHP information on the webpage.


If you have any questions or suggestions, let us know in the comments. Also check out this guide if you want to learn how to  install and secure MariaDB on a Debian 10 server .


NT
بواسطة : NT
Information aims to help you progress in improving your site. Commitment to provide maximum value to you through your written content.
Comments



Font Size
+
16
-
lines height
+
2
-