Install Apache, MySQL and PHP 8 (LAMP) on Ubuntu 20.04 LTS

In this guide we’ll see how to install PHP , Apache, MySQL/MariaDB on Linux and Ubuntu 20.04.

Installing Apache on Ubuntu 20.04

Let’s get started by installing Apache on our Ubuntu 20.04 machine. Open a new terminal and run the following commands:

Next, you need to enable Apache to start on boot using the following command:

Installing MySQL/MariaDB

Next, let’s install MariaDB, a drop-in replacement for MySQL. In your command-line interface run the following command:

Next, you need to rnable MariaDB to start on boot using the following command:

After that. it’s a best practice to secure the database. Run the following command:

You’ll be prompted for a bunch of questions which you need to answer according to your security preferences.

Installing PHP 8 on Ubuntu 20.04

Now, let’s install PHP 8 and its common extensions as follows:

Next, you need to restart Apache to load PHP.


In this guide, you have seen how to install a LAMP stack on your Ubuntu 20.04 LTS system. For more information about LAMP, see the official documentation:

Web developer and system admin