How To Install LAMP Stack on Debian 10
LAMP Stack stands for Linux, Apache, MariaDB, and PHP stack. These four popular open source software components are used by most of the web hosting companies, web developers, blogs, and others to host websites.
Install LAMP Stack
Follow the Step by Step installation of Debian 10 or Upgrading Debian 9 Stretch to Debian 10 Buster to have Debian OS.
Now, we will proceed to the install Apache v2.4, PHP v7.3, MariaDB v10.3 on Debian 10.
First, we will install the Apache web server.
Update the package repository index.
sudo apt update
Install Apache server package using the
sudo apt install -y apache2 apache2-utils
Check the status of the Apache server.
sudo systemctl status apache2
We will now test the Apache web server to check if it is working correctly or not.
Open up a web browser and then go to the following URL.
You will get the “Apache2 Debian Default Page“. This page confirms that the Apache server is working fine.
Apache HTTP server’s default document root is
/var/www/html/ on Debian and the main configuration file is
/etc/apache2/apache2.conf. Additional configuration files are found in the
MariaDB is the popular database server and it is the drop in replacement of MySQL server, developed by the original developers of MySQL.
Install MariaDB server using the following command
sudo apt install -y mariadb-server mariadb-client
Check the status of MariaDB service.
sudo systemctl status mariadb
mysql_secure_installation command to improve the security of your MariaDB installation.
READ: How to Secure MariaDB installation using mysql_secure_installation
By default Apache server supports the .html documents only, not PHP. To support PHP, you need to install PHP and the PHP extension package for MariaDB to connect the database.
sudo apt install -y php php-mysql libapache2-mod-php
You would need to restart the Apache server after the installation of the PHP package.
sudo systemctl restart apache2
Test LAMP Stack
To test a PHP 7.3, we will place a .php file on the default document root of Apache server.
The output will display lots of useful details about our PHP installation, such as the installed PHP version, PHP extension details.
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Now open a web browser and go to the following URL.
The page will look like below,
You can also see MariaDB support for PHP.
You have successfully installed the LAMP Stack on Debian 10. Please share your feedback in the comments section.