How to Install LAMP Stack on Debian 10

The term LAMP is an acronym of the names of its four open-source components:

  • L - Linux operating system
  • A - Apache, an HTTP and reverse proxy server
  • M - MySQL or MariaDB relational database management system
  • P - PHP programming language.

In this series, we’ll cover how to install a LAMP stack on Debian 10. We will show you how to install Apache, generate a free Let’s Encrypt SSL certificate, install, and secure MariaDB, and install PHP 7.

The detailed tutorials that are part of this series are listed at the end of this page.

If you are in a hurry and don’t want to read more detailed documentation, you can install LAMP Stack on your Debian 10 server by following our Quickstart section.

Install LAMP Stack on Debian 10 [Quickstart]

This quickstart shows the basic steps required to get a LAMP stack installed on Debian 10.

Prerequisites

The user you are logged in as must have sudo privileges to be able to install packages.

Step 1. Installing Apache

Installing Apache is a pretty straightforward process. On Debian based distributions, the Apache package and the service is called apache2.

Update the packages index and install Apache by running the following commands:

sudo apt updatesudo apt install apache2

Step 2. Installing MySQL

MariaDB is the default database system in Debian 10. To install it on your server, type:

sudo apt install mariadb-server

Once the installation is completed, issue the mysql_secure_installation command to improve the security of the MariaDB installation:

sudo mysql_secure_installation

You will be asked to set the root password, remove the anonymous user, restrict root user access to the local machine and remove the test database. You should answer “Y” (yes) to all questions.

If you want to install MySQL instead of MariaDB, check our tutorial for installation instructions.

Step 3. Installing PHP

Debian 10 ships with PHP version 7.3. To install PHP and most common PHP modules, use the following command:

sudo apt install php libapache2-mod-php php-opcache php-cli php-gd php-curl php-mysql

Once the PHP packages are installed, restart the Apache service with:

sudo systemctl restart apache2

More Information

For more detailed instructions about each step, please consult the following tutorials.

Tutorials