This article will help you to Install Apache 2.4, MySQL 8.0 and PHP 7.4 on Ubuntu 20.04 LTS (Focal Fossa) system. Let’s begin the installation of LAMP stack your Ubuntu machine.


You must have root or sudo privileged user access to your Ubuntu 20.04 system. Login to your Ubuntu system using GUI for Desktop and SSH for the server edition. Now upgrade current packages to latest version. Follow the initial server setup instruction to get ready your system for working.

Step 1 – Installing Apache2

Apache2 is a powerful web server software used by large number of websites. This is the first component to install in order to setup LAMP on Ubuntu 20.04 system. To install the Apache2 package, type: Once the Apache2 package installation completed, check the service status: The Apache service is active and running. Now, open a web browser and enter IP address of your server. You will see the default Apache web page

All the configuration file are stored under /etc/apache2 directory. To create additional virtual hosts visit this tutorial.

Step 2 – Installing PHP

PHP 7.4 packages are available under the default Apt repositories on Ubuntu 20.04 LTS. To install PHP on your system, update apt index and then install it on your system. Also install additional PHP modules required for your application.

Step 3 – Installing MySQL Server

The default Ubuntu 20.04 apt repositories contains MySQL server 8.0. Finally, install mysql-server packages for the MySQL database. Also, install the php-mysql package to use MySQL support using PHP. Use the following command to install it. The installer will prompt for the root password, This password will work for your MySQL root user. After installing MySQL execute the following command for initial settings of MySQL server. You will see that script will prompt for more settings than earlier MySQL versions like password validation policy etc.

Step 4 – Installing phpMyAdmin (optional)

phpMyAdmin provides a user friendly web interface to manage MySQL database server. You can install phpMyAdmin on Ubuntu 20.04 by executing the following command: The installation process will prompt to select web server to configure. Select “Apache” as web server to run phpMyAdmin. Next, this will prompt to create database for phpMyAdmin and prompt for the administrative user access details. Complete all steps to finish phpMyAdmin installation.

Step 5 – Manage Services

We have done with the installation of LAMP stack on Ubuntu 20.04 LTS system. The below commands will help you to start/stop or restart Apache and MySQL services running with systemd. To restart Apache and MySQL services, type: To start Apache and MySQL services, type: To stop Apache and MySQL services, type:

Step 6 – Adjusting Firewall Rules

You can directly provide a service name like “http” or “https” to allow. The firewalld uses /etc/services file to determine the corresponding port of the service.

Step 7 – Test Setup

After completing all setup. Let’s create a info.php file website document root with following content. Now access this file in web browser. You will see the screen like below with all details of PHP on server.

Also access the phpMyAdmin

Congratulation’s! You have successfully configured web server on your Ubuntu 20.04 LTS system. Read our next article Installing LAMP Stack on RHEL based systems

How to Install Apache  MySQL  PHP  LAMP Stack  on Ubuntu 20 04 - 57How to Install Apache  MySQL  PHP  LAMP Stack  on Ubuntu 20 04 - 56How to Install Apache  MySQL  PHP  LAMP Stack  on Ubuntu 20 04 - 66