Install Apache2, PHP 7.2 and MariaDB 10.5 on Debian 11

First, update all the packages of the system by below-mentioned command:

sudo apt update

After updating packages, now install the dependencies required by the below-mentioned command:

sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https

Enable SURY Repository

The following step is to integrate the SURY repository into our system. SURY is a Debian-based third-party PHP repository that bundles PHP software, run the following command to add SURY repository:

sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Importing the GPG key for the repository by the below-mentioned command:

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

Installing PHP on Debian 11

Now again update packages for syncing them with the recently added SURY repository before installing php:

sudo apt update

The SURY repository contains PHP 8.2, 8.1, 8.0, 7.4, 7.3, 7.2. 7.1, 7.0 & PHP 5.6. As the latest stable version of PHP is 8.0, but a large number of websites still required PHP 7. You can install any of the required PHP versions on your system.

Install PHP 8.2 on Debian sudo apt install php8.2 
Install PHP 7.2 on Debian sudo apt install php7.2 
Install PHP 5.6 on Debian sudo apt install php5.6

Replace version 8.2, 7.2 or 5.6 with the required PHP version to install on your Debian system. Even you can install multiple PHP versions on a single Debian system.

Now Installing  LAMP

apt install gnupg git apache2 php7.2 libapache2-mod-php php7.2-mysql php7.2 php7.2-cgi php7.2-mysqli php7.2-mbstring php7.2-common php7.2-mysql mariadb-server mariadb-client phpmyadmin

Now you can go ahead and secure mariadb. Good Luck!

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.