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

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:

$ sudo apt install apache2 -y
$ sudo systemctl start apache2.service
$ sudo systemctl enable apache2.service

Installing MySQL/MariaDB

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

$ sudo apt install mariadb-server mariadb-client -y
$ sudo systemctl enable mariadb.service
$ sudo mysql_secure_installation

Installing PHP 8 on Ubuntu 20.04

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

$ sudo apt install php php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,fpm} -y
$ sudo systemctl restart apache2.service


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:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store