A LAMP environment is the combination of Linux, Apache, MySQL & PHP. Here Apache is the popular web server, MySQL is the relation database management system and PHP is programming language generally used for developing web applications.
Most of the websites are build with PHP and MySQL, which is hosted with LAMP environment. For example, the popular blogging web platform WordPress, Drupal are developed with PHP and MySQL. Both are widely hosted over the LAMP environment.
This tutorial will help you to install and configure LAMP environment on your Debian 10 Linux system.
You must have sudo privileges account access to the Debian 10 Linux system.
Login to your Debian 10 system and upgrade the current packages to the latest available version.
sudo apt update && sudo apt upgrade
Also, install the below packages on your system required for commands next in this tutorial.
sudo apt install ca-certificates apt-transport-https
Step 1 – Installing Apache
The Debian 10 base repositories contain Apache 2.4 packages. You can simply install latest Apache2 packages by running the following command:
sudo apt install apache2
Step 2 – Installing MySQL Server
The default Debian 10 repository contains MariaDB (Replacement of MySQL) as default database server. If you are okay to go with MariaDB execute commands to install else follow MySQL server installation tutorial.
sudo apt install mysql-server
Once the MySQL packages installed, execute the fowlloing to configure MySQL server for first time.
This is start a configuration wizard. Configure the MySQL root user password and follow other steps to complete the configuration part.
Step 3 – Installing PHP
Default Debian 10 system repositories contain an older PHP version. To install the latest PHP version add a third-party PPA to your system. Run the below command to add PPA to your system.
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add - sudo echo "deb https://packages.sury.org/php/ buster main" | tee /etc/apt/sources.list.d/php.list
Then install the latest PHP version on Debian 10.
sudo apt update sudo apt install php php-mysql libapache2-mod-php
Step 4 – Test Setup
To verify the LAMP setup on your system, Create a PHP script with phpinfo() function under Apache document root. To do this, edit /var/www/html/info.php file in your favorite text editor and add below content to the file and save it.
Now access the info.php file in the web browser using your system IP address.
This tutorial helped you to setup LAMP environment on a Debian 10 Buster Linux system.