Setting Up a LAMP Stack on Ubuntu 20.04

A LAMP stack is a collection of software that's commonly used for building and running web applications. LAMP stands for Linux, Apache, MySQL, and PHP. In this tutorial, we will guide you through the process of setting up a LAMP stack on Ubuntu 20.04.

5 mins read

0 views

LAMP

Not using Ubuntu 20.04?

Choose a different version or distribution.

Step 1: Install Apache

Apache is a popular web server that's used to serve web pages. To install Apache on Ubuntu 20.04, open the terminal and run the following command:

sudo apt-get update
sudo apt-get install apache2

After the installation is complete, start the Apache service by running the following command:

sudo systemctl start apache2

To verify that Apache is installed and running correctly, open your web browser and navigate to "http://localhost". If Apache is installed and running correctly, you should see the Apache default page.

Step 2: Install MySQL

MySQL is a popular relational database management system that's commonly used for storing data for web applications. To install MySQL on Ubuntu 20.04, open the terminal and run the following command:

sudo apt-get install mysql-server

After the installation is complete, start the MySQL service by running the following command:

sqlsudo systemctl start mysql

Next, run the following command to secure the MySQL installation:

sudo mysql_secure_installation

This command will guide you through the process of setting the MySQL root password, removing anonymous users, and other security-related tasks.

Step 3: Install PHP

PHP is a popular server-side scripting language that's used for building dynamic web pages. To install PHP on Ubuntu 20.04, open the terminal and run the following command:

sudo apt-get install php libapache2-mod-php php-mysql

After the installation is complete, restart the Apache service by running the following command:

sudo systemctl restart apache2

Step 4: Test the LAMP Stack

To test the LAMP stack, create a new PHP file named "info.php" in the Apache document root directory (/var/www/html) with the following contents:

<?php phpinfo(); ?>

Save the file and then open your web browser and navigate to "http://localhost/info.php". If the LAMP stack is installed and running correctly, you should see the PHP information page.

Step 5: Optional - Install phpMyAdmin

phpMyAdmin is a web-based tool for managing MySQL databases. To install phpMyAdmin on Ubuntu 20.04, open the terminal and run the following command:

sudo apt-get install phpmyadmin

During the installation process, you will be asked to configure phpMyAdmin. Choose Apache as the web server, and then follow the prompts to complete the configuration.

Conclusion

In this tutorial, we have shown you how to set up a LAMP stack on Ubuntu 20.04. A LAMP stack is a popular combination of software that's commonly used for building and running web applications. By following the steps in this tutorial, you can easily set up a LAMP stack on your Ubuntu 20.04 system.