How To Install Linux, Apache, MySQL, PHP (LAMP) Stack On Ubuntu 20.04

How To Install LAMP Stack On Ubuntu

This article will guide you about How to Install LAMP Stack on Ubuntu 20.04. A software stack is a bundle of software tools. LAMP’s full form is Linux, Apache, MariaDB/MySQL, and PHP, all of these are open source tools and completely free to use. it’s the most common software stack that powers dynamic websites and web applications.

The term LAMP is an acronym that represents its four open-source elements:

  • L – Linux operating system
  • A – Apache, a webserver, and reverse proxy server
  • M – MariaDB or MySQL relational database management system
  • P – PHP, a programming language.

This article will explain to you how to install an Apache web server, create virtual hosts, install a free Let’s Encrypt SSL certificate, install and configure MySQL, and install PHP 7.4.

Install Linux, Apache, MySQL, PHP (LAMP)  Stack On Ubuntu 20.04

The detailed tutorials for each service are bookmarked at the end of this page, go with them for detailed installation one by one.

If you are sort in time, you can install LAMP Stack on your Ubuntu 20.04 server by following this section.

Read Also: How to install Docker on Ubuntu 20.04?

Install LAMP Stack on Ubuntu 20.04

This article shows the basic steps required to install and configure LAMP on an Ubuntu 20.04 server.

Prerequisites

The user you are logged in as must be either a root user or have sudo privileges to install packages.

Step 1. Installing Apache

Apache package is already there in Ubuntu repositories, So we just need to install the package by running the below commands:

sudo apt update -y
sudo apt install apache2 -y

That’s it for apache installation, it has been configured with the default configuration. Default document root directory is /var/www/html.

Step 2. Installing MySQL

Now next we need to install MySQL or MariaDB Server for anyone from both of them. To start the installation by below command:

sudo apt install mysql-server -y

Once the installation gets completed, run the mysql_secure_installation command and follow the options to set the password and improve the security of MySQL.

sudo mysql_secure_installation

You will be asked a few questions some of them will be related to setting the root password, removing any anonymous user, restricting root user access to the local host, and removing the test DB.
You should press “Y” to answer (yes) to all the questions.

Step 3. Installing PHP

Ubuntu 20.04 LTS comes with PHP version 7.4 that is the latest version. To install a PHP package with a few common PHP modules run the following command.

sudo apt install libapache2-mod-php php php-mbstring php-opcache php-cli php-gd php-curl php-mysql php-zip php-xml -y

When done, restart the Apache service:

sudo systemctl restart apache2

Conclusion

This guide should help you to install the LAMP stack on your Ubuntu 20.04 server without any issues. This is quite a short version with just basic commands. we are going to post more articles for each service individually that was the part of this article that will have installation and configuration both.