×



LAMP stack stands for Linux Apache MySQL/MariaDB and PHP. Apache is a free and open-source and extremely popular webserver. MySQL / MariaDB is an opensource relational database management system and PHP is a server-side scripting language. It is basically one of the most popular and leading development stacks among developers. 

Here at LinuxAPT as part of our Server Management Services, we regularly help our Customers to perform related Apache queries.

In this context, we shall look into LAMP on Debian 11. You can learn how to install LAMP on Rocky Linux 8 and CentOS 8.


How to Install LAMP Server on Debian 11 ?

Before proceeding with this Installation procedure, ensure that you have a sudo user configured on the server and then follow the below outlined steps to install the popular LAMP stack on Debian Bulleye.


1. Update Debian 11 system apt packages

It is important to update your system package index to start off on a clean slate. Therefore, On your terminal, run the below command:

$ sudo apt update -y


2. Install Apache webserver

Here, install Apache webserver  by running the command:

$ sudo apt install apache2 -y

What this command does is that it installs Apache alongside other additional packages, libraries, and dependencies. By default, Apache autostarts and you can confirm this by checking its status with the below command:

$ sudo systemctl status apache2

If, for whatever reason, Apache is not running, start the service by running the command:

$ sudo systemctl start apache2

Additionally, consider enabling Apache to start upon a reboot or every time the system is powered on as follows:

$ sudo systemctl enable apache2

On a web browser, visit your server's IP address or domain name to verify that, indeed, the webserver is accessible:

http://server-ip

Now you should see the Apache webserver welcome page which is Apache2 Debian Default Page.


3. Install MariaDB database server

MariaDB is an opensource relational database management system ( RDBMS) that is forked from MySQL. It’s more robust, more secure and provides additional features such as Galera cluster, and cool storage engines such as InnoDB

To install the MariaDB server, simply run the command:

$ sudo apt install mariadb-server -y

Like Apache, MariaDB starts automatically. You can verify the running status by executing the command:

$ sudo systemctl status mariadb

If MariaDB is not running considering starting it:

$ sudo systemctl start mariadb

Then enable the service to start on boot time:

$ sudo systemctl enable mariadb


4. Secure MariaDB database server

It is very essential to secure the database server. The default settings that MariaDB ships with are weak and can hackers can exploit them to breach the database.

So, to harden MariaDB, run the command:

$ sudo mysql_secure_installation

This will pop up a few prompts which will guide you in hardening your server. Begin with setting a root password

Then type 'Y' for the remaining prompts to configure the database server to the most recommended security settings.

To log in run the command:

$ sudo mysql -u root -p

Type the root password and hit ENTER. To existing databases run the command:

SHOW DATABASES;

To confirm the version of MariaDB, run:

SELECT VERSION();

To exit the database server, run the command:

EXIT;


5. Install PHP

Now, we will install PHP, which is a server-side scripting language used for supporting the development of dynamic web pages. By default, PHP 7.4 is hosted on Debian 11 repository. Therefore, we will install PHP and some additional PHP modules using the APT package manager as executed below:

$ sudo apt install php libapache2-mod-php php-zip php-mbstring php-cli php-common php-curl

You can confirm if PHP is installed using the command:

$ php -v

Also, you can verify this from a web browser by creating a sample PHP file in the document root folder:

$ sudo nano /var/www/html/info.php

Paste the following lines:

<?php
phpinfo();
?>

Save the file and browse the URL:

http://server-ip/info.php

Now, You should get the PHP page displaying its version as well as the extensions.


[Need assistance in fixing Apache issues? We can help you. ]


Conclusion


More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com