“TeckMile.com – Elevating Your Skills and Creativity, One Project at a Time.”

How to Install a LAMP Stack on Debian 11

In this tutorial, we’ll guide you through the process of setting up a LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack on a Debian 11 server. A LAMP stack is a popular choice for hosting dynamic websites and web applications. Let’s get started!

Step 1: Install Apache Web Server

We’ll begin by installing the Apache web server:

sudo apt-get install apache2 apache2-utils -y

Now, start Apache:

sudo systemctl start apache2

To ensure Apache starts on boot, enable it:

sudo systemctl enable apache2

You can check the status of Apache with:

systemctl status apache2

Note: To see the default Apache webpage, open your web browser and navigate to your server’s IP address.

Step 2: Install MariaDB Database Server

Next, we’ll install MariaDB, a powerful and secure database server:

sudo apt-get install mariadb-server -y

Start MariaDB:

sudo systemctl start mariadb

Enable MariaDB to start on boot:

sudo systemctl enable mariadb

Check the status of MariaDB:

systemctl status mariadb

Now, let’s secure your MariaDB installation using the script:

sudo mysql_secure_installation

Follow the prompts to set a new root password, remove anonymous users, disallow remote root login, and remove the test database.

Step 3: Install PHP

Install PHP and some essential modules for Apache:

sudo apt install php -y
sudo apt-get install php libapache2-mod-php php-cli php-mysql php-zip php-curl php-xml -y

To verify the PHP installation and check its version, run:

php -v

Conclusion:

Congratulations! You’ve successfully set up a LAMP stack on your Debian 11 server. You’re now ready to develop and host dynamic web applications.

This guide provides a solid foundation for hosting web applications, and you can build on it for more complex projects.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *