Most of the websites are built with PHP and MySQL, which is hosted with LAMP environment. For example, the popular blogging web platforms WordPress, Drupal are developed with PHP and MySQL. Both are widely hosted over the LAMP environment. This how-to guide helps you to install and configure LAMP Stack on a Debian 10 Linux system.

Prerequisites

You must have sudo privileges account access to the Debian 10 Linux system. Login to the Debian 10 system and upgrade the current packages to the latest available versions. Also, install the below packages on your system required for commands next in this tutorial.

Step 1 – Installing Apache

Apache 2.4 packages are available under the default repositories of Debian 10 system. You can simply install latest Apache2 packages by running the following command: The above command also add some dependent packages in your system. The installer will automatically start Apache2 service, You can verify this using the following command: You should find the Apache in running status. Now access your server IP address or a domain name pointed to the server’s IP address in the web browser. You will find the default landing page as showing below: In my case, I have pointed a subdomain debian10.tecadmin.net to the Debian 10 system. Then accessing it in a web browser, like:

Step 2 – Installing MySQL

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. Once the MySQL packages installed, execute the following to configure the MySQL server for the first time. The above command will start a configuration Wizard. Follow on-screen instructions. We have included steps that required user input as below: The database wizard is completed now. Your server is ready to access. Type below command to get access to the MySQL server shell. Output:

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. Next, update the Apt cache on your system: The install the PHP along with the required modules. To install the latest PHP version, execute the following command else go to the next command to install a specific PHP version. Press ‘y’ for the confirmation to complete the installation process.

Step 4 – Verify PHP Version

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 a web browser using your system IP address or a domain name pointed to that IP address.

That’s it. You have successfully installed Apache, MySQL, and PHP on your Debian 10 Linux system.

Step 5 – Secure Apache with Let’s Encrypt

The SSL certificate can be issued for a domain or subdomain only. As we have already pointed a subdomain to our Debian 10 system IP address. Now create a Virtualhost configuration file in Apache for the domain. The domain name will be changed in your case. So update debian10.tecadmin.net with your domain name for the below commands and configuration. Add the following content to the file. Make sure to change your Server Name and document root to the correct location

Save and close the configuration file. Next, enable the Apache configuration file. This will make a link of the configuration file from the sites-available directory to the sites-enabled directory. Reload the Apache configuration to reload settings: You have an active site configured in the Apache server. Now, install the Certbot Let’s Encrypt client along with the Apache plugin on your Debian system. Execute the below commands to install the Certbot. Once the installation finished. Run the following command to request an SSL certificate. This command will scan all the sites configured in Apache. During the first run, the command will ask you to provide an email address and take consent to sent SSL alerts like renewing, etc. Then it will list all the sites configured in Apache and prompt to input the site id to issue the certificate for that. In my case, the site id is 1. You can select multiple sites with command separate ids. Once the authorization completed, the command will prompt to configure auto redirection. Select any number of our choice and requirements. All done, This will create an additional Apache configuration file with a newly issued certificate to listen on TLS/SSL on port 443. Now access your domain again in the browser and verify the SSL certificate.

Conclusion

This tutorial helped you to set up the LAMP environment on a Debian 10 Buster Linux system. Additionally provides you instructions to secure Apache with a Let’s Encrypt SSL certificate.

How To Install LAMP  Apache  MySQL  PHP  on Debian 10 - 13How To Install LAMP  Apache  MySQL  PHP  on Debian 10 - 82How To Install LAMP  Apache  MySQL  PHP  on Debian 10 - 91How To Install LAMP  Apache  MySQL  PHP  on Debian 10 - 34