How To Install LAMP Stack on Debian 10

0

ADVERTISEMENT

THIS DOCUMENT IS ALSO AVAILABLE FOR

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

Install Linux

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.

Install Apache

First, we will install the Apache web server.

Update the package repository index.

sudo apt update

Install Apache server package using the apt command.

sudo apt install -y apache2 apache2-utils

Check the status of the Apache server.

sudo systemctl status apache2
Install LAMP Stack on Debian 10 - Apache Web Server Service Status
Install LAMP Stack on Debian 10 – Apache Web Server Service Status

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.

http://localhost/

OR

http://your-ip-add-ress/

You will get the “Apache2 Debian Default Page“. This page confirms that the Apache server is working fine.

Install LAMP Stack on Debian 10 - Apache2 Default Page
Install LAMP Stack on Debian 10 – Apache2 Default Page

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 /etc/apache2 directory.

Install MariaDB

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.

ADVERTISEMENT

sudo systemctl status mariadb
Install LAMP Stack on Debian 10 - MariaDB Service Status
Install LAMP Stack on Debian 10 – MariaDB Service Status

Run the mysql_secure_installation command to improve the security of your MariaDB installation.

sudo mysql_secure_installation

READ: How to Secure MariaDB installation using mysql_secure_installation

Install PHP

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.

http://localhost/info.php

OR

http://your-ip-add-ress/info.php

The page will look like below,

Install LAMP Stack On Debian 10 - PHP Information
Install LAMP Stack On Debian 10 – PHP Information

You can also see MariaDB support for PHP.

Install LAMP Stack on Debian 10 - PHP MariaDB Support
Install LAMP Stack on Debian 10 – PHP MariaDB Support

Conclusion

You have successfully installed the LAMP Stack on Debian 10. Please share your feedback in the comments section.

You might also like