---
title: How To Set Up LAMP Stack On Ubuntu 20.04
description: "The LAMP stack is a popular choice for developing and hosting web applications. It is free, open-source, and relatively easy to set up and maintain. The LAMP stack combines these four components to create a robust web development and hosting…"
url: "https://truehost.com/support/knowledge-base/set-up-lamp-stack/"
updated: "2024-06-07"
---

# How To Set Up LAMP Stack On Ubuntu 20.04

The LAMP stack is a popular choice for developing and hosting web applications. It is free, open-source, and relatively easy to set up and maintain.

The LAMP stack combines these four components to create a robust web development and hosting environment:

- Linux is the operating system that provides stability and security as the foundation for web applications.
- Apache acts as the web server, capable of handling high traffic volumes and supporting various web technologies. 
- MySQL functions as the database server, offering reliability and scalability for storing important data. 
- PHP serves as the scripting language, enabling the development of dynamic web applications.

With the LAMP stack, diverse web applications can be developed, including:

- Content management systems (CMS) allow users to create and manage web content without requiring coding knowledge.
- E-commerce platforms facilitate the online selling of products and services.
- Social networking sites enable users to connect with friends and family online.
- Intranets: Private networks used by organizations to share information and resources with employees.
- Extranets: Semi-private networks utilized by organizations to share information and resources with partners and customers.

The LAMP stack offers versatility and power, making it a valuable tool for various web application development needs. 

It’s an excellent option if you seek a reliable, affordable solution for developing and hosting web applications.

## **Let’s Set Up LAMP Stack ;**

To set up the LAMP stack (Linux, Apache, MySQL, PHP, and PhpMyAdmin) on Ubuntu 20.04, you can follow the steps below:

1. Update System Packages- ensure your system is up-to-date and that the new applications to run smoothly. Apply these codes on the terminal:

*“sudo apt update and sudo apt upgrade”*

1. Now, let’s install Apache Web Server using this code:

*“sudo apt install apache2.” *

Once complete, verify the installation by opening a browser. Visit “[http://localhost](http://localhost)” You should see the Apache default page if the installation was successful.

1. Install MySQL- type in the following code.

*“sudo apt install mysql-server” and “sudo mysql_secure_installation”*

Follow the prompts to set a root password and answer the security-related questions.

1. Install PHP by this code;

*“sudo apt install php libapache2-mod-php php-mysql”*Now configure Apache to use PHP:

*“sudo nano /etc/apache2/mods-enabled/dir.conf”*

Move the `index.php` file before `index.html` within the `<IfModule mod_dir.c>` section. Save and exit the file.

1. Restart Apache using this code: 

*“sudo systemctl restart apache2”*

Test PHP- Create a PHP info file to verify that PHP is working correctly.

*“echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php”*

Open your browser and visit “*http://localhost/info.php*.” You should see the PHP information page.

1. Install PhpMyAdmin:

Type in “sudo apt install PhpMyAdmin” on your terminal. During the installation, choose `Apache2` when prompted.

Then select 'Yes' when asked if you want to configure the database with “dbconfig-common”.

Configure PhpMyAdmin by:

* “sudo nano /etc/apache2/conf-available/phpmyadmin.conf”*

Add the following line at the bottom of the file, just after the last `</Directory>` line include *“/etc/phpmyadmin/apache.conf”*

Save and exit the file. Now enable the PhpMyAdmin configuration:

*sudo ln -s /etc/apache2/conf-available/phpmyadmin.conf/ etc/apache2/conf-enabled/phpmyadmin.conf*

1. Now Restart Apache by “sudo systemctl restart apache2” Then access PhpMyAdmin on the web browser *“*[*http://localhost/phpmyadmin*](http://localhost/phpmyadmin)*.”*

You should see the PhpMyAdmin login page.

## Finally

That's it! You have successfully set up the LAMP stack (Apache, MySQL, PHP, and PhpMyAdmin) on Ubuntu 20.04.
