In this article, we will have explained the necessary steps to install and configure the LAMP Stack on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with
sudo privileges. All the commands in this tutorial should be run as a non-root user.
LAMP is a complete package to run any web application on a server. LAMP stands for Linux, Apache, MariaDB, and PHP stack. Apache is used as the webserver for hosting an application whereas MySQL/MariaDB is used as systematic data storage of applications and PHP is a popular server-side scripting language that is used for web development as well as bridging the gap between application and the database.
Install LAMP Stack on Debian 10
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo apt update sudo apt upgrade
Step 2. Install Apache.
Apache Webserver packages are available on Debian 10 official repositories. All that’s needed is the execution of the install command with
sudo apt install apache2 apache2-utils
After completion of the above command, Apache is installed on your system. Run the following command to check the apache service status:
sudo systemctl status apache2
You can also start, stop, restart and get the status of the Apache web server using the following
sudo systemctl start apache2.service sudo systemctl restart apache2.service sudo systemctl stop apache2.service sudo systemctl reload apache2.service
Confirm Apache build and version:
sudo apache2 -v
Step 3. Install MariaDB.
MariaDB is a relational database management system forked from MySQL. It is free and Open-source. Install the MariaDB server using the following command:
sudo apt install mariadb-server mariadb-client
Once MariaDB is installed, it is recommended to run the following security script that will remove some insecure default settings and disable access to your database system:
To create a database and grant your users permission to use databases, run:
# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE example_database; MariaDB [(none)]> GRANT ALL ON example_database.* TO 'example_user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
Step 4. Install PHP 7.3.
At the time of this writing, PHP7.3 is the latest stable version of PHP and has minor performance improvements over previous versions. To install the PHP package, run the following command:
sudo apt install php7.3 libapache2-mod-php7.3 php7.3-mysql php-common php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-readline
Enable the Apache php7.3 module then restart the Apache Web server:
sudo a2enmod php7.3 sudo systemctl restart apache2
One can get a list of all PHP modules using the combination of the
apt-cache command and grep command:
apt-cache search php | egrep 'module' | grep default
Confirm your PHP version:
# php -v PHP 7.3.3-1 (cli) (built: May 16 2019 19:46:34) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.3-1, Copyright (c) 1999-2018, by Zend Technologies
Step 5. Testing PHP
Now you should create
info.php file to test PHP to do so type the following:
echo "" | sudo tee /var/www/html/info.php
Then open the following link in your web browser and we will be able to see all the information about PHP and its other configurations:
http://your-domain/phpinfo.php (replacing your IP address with the one above).
That’s all you need to do to install the LAMP stack on Debian 10 Buster. I hope you find this quick tip helpful. For further reading on LAMP, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.