Install Apache,Mariadb and Php on Debian 11 Bullseye
LAMP stands for Linux, Apache, MySQL, and PHP. Together, they provide a proven set of software for delivering high-performance web applications. The Apache web server processes requests and serves up web assets via HTTP so that application is accessible to anyone in the public domain over a simple web url. open source relational database management for storing application data. With My SQL, you can store all your information in a format that is easily queried with the SQL language. The PHP open source scripting language works with Apache to help you create dynamic web pages.
In this article, we will show you how to install apache,mariadb and php on debian11 system.
Step 1: Install Apache
we need to update packages with apt and install apache web server.
sudo apt update apt install apache2 apache2 - utils
once apache is installed, check the service status using following command.
sudo systemctl status apache2
you can check apache version as below.
sudo apache2 -v
Server version: Apache/2.4.48 (Debian) Server built: 2021-08-12T11:51:47
Also Read -> How to Install JAVA on Debian 11
Step 2: Install Mariadb
you can install mariadb from debian base repository.
sudo apt install mariadb-server
After MariaDB is installed, start the MariaDB service and enable it to start at system boot and check the status with below commands.
sudo systemctl start mariadb sudo systemctl enable mariadb sudo systemctl status mariadb
● mariadb.service - MariaDB 10.5.11 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-09-01 05:16:49 PDT; 22min ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 3873 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
you can check the version using below command.
sudo mariadb --version
Then run the mysql_secure_installation script to secure the MariaDB.
then it prompts to set mariadb Mariadb root password, remove anonymous users, remove test db etc.
Switch to unix_socket authentication [Y/n] y Change the root password? [Y/n] y New password: Re-enter new password: Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
Now you need to provide username and password to access MySQL console.
sudo mysql -u root -p
it promts to mariadb root password. once you login to mariadb shell, you can check version using SELECT VERSION() command as below.
root@debian:~# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 52 Server version: 10.5.11-MariaDB-1 Debian 11 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SELECT VERSION(); +-------------------+ | VERSION() | +-------------------+ | 10.5.11-MariaDB-1 | +-------------------+ 1 row in set (0.001 sec) MariaDB [(none)]>
then type exit to close the shell.
Step 3: Install php
By default, the version of PHP available in the Debian 11 is PHP 7.4.we need to install Php and Php extension package for MariaDB to connect with the db.
sudo apt install php php-cli php-mysql libapache2-mod-php php-gd php-xml php-curl php-common
you can check the php version as below.
PHP 7.4.21 (cli) (built: Jul 2 2021 03:59:48) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
Then you must restart apache service using the following command.
sudo systemctl restart apache2
Step 4: Test php on Apache
Now you can create sample php file as info.php in the default document root of apache server as below.
Add below lines to above file.
<?php phpinfo(); ?>
save the file and exit.
Then open your browser in your system and type http://ip_address/info.php
That's it. Now you have successfully installed LAMP stack on Debian 11 server.
Also Read -> How to Install php 8 on Debian 11 Bullseye