This tutorial will show you how install LAMP stack on Debian 11 Linux server. The abbreviation LAMP stands for Linux, Apache, MariaDB/MySQL, and PHP. The LAMP Stack is a collection of open-source tools that are used to power online applications and webpages. Each component may be utilized to serve an application on its own.
Install LAMP Stack on Debian 11
Run System Update
Ensure the system package cache is up to date before you begin to install LAMP Stack on Debian 11.
sudo apt update
sudo apt upgrade
Install Apache Web server
After you’ve completed the system update, you may install Apache, the web server. The Apache web server is included in the Debian 11 Buster repositories and may be installed using the command below.
sudo apt install apache2-utils apache2 -y
Check the Apache version.
sudo apache2 -v
Server version: Apache/2.4.48 (Debian)
Server built: 2021-08-12T11:51:47
Now, check the status of apache2 using the following command.
systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-09-02 21:19:53 EAT; 48s ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 2568 (apache2)
Tasks: 55 (limit: 2325)
Memory: 10.5M
CPU: 87ms
CGroup: /system.slice/apache2.service
├─2568 /usr/sbin/apache2 -k start
├─2570 /usr/sbin/apache2 -k start
└─2571 /usr/sbin/apache2 -k start
Sep 02 21:19:53 bett systemd[1]: Starting The Apache HTTP Server...
Sep 02 21:19:53 bett apachectl[2567]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName>
Sep 02 21:19:53 bett systemd[1]: Started The Apache HTTP Server.
You may test if Apache is ready to serve web requests by opening a web browser and typing http://<server-IP> into the address bar. The Apache2 Debian Test page should greet you.
Install MariaDB on Debian 11
We’ll be using MariaDB 10.6 in this tutorial. Follow the link below to learn how to install MariaDB 10.6 on Debian 11;
Install MariaDB 10.6 on Debian 11
Install PHP on Debian 11
We’ll set up PHP and some of the most widely used extensions. PHP 7.4 is the version of PHP installed in Debian 11.
sudo apt install php php-cli php-fpm php-json php-pdo php-mysql libapache2-mod-php
Now, confirm your PHP version:
php -v
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
To test your LAMP stack installation, write a php script as below. We will create a test.php
script under /var/www/html directory.
Add the following content to the file created above.
cat > /var/www/html/test.php << EOL
<?php
phpinfo();
?>
EOL
To test PHP processing, open a browser and type http://<server-IP>/test.php in the address bar.
You will get the following page:
Now, remove the PHP test page.
sudo rm -rf /var/www/html/test.php
Conclusion
This concludes our tutorial on how to install LAMP stack on Debian 11 Linux server.