April 20, 2023

How To Install LAMP Stack On Ubuntu 20.04

Abhishek Thakur

LAMP stack is a popular web development stack that includes Linux, Apache, MySQL, and PHP. In this blog, we will show you how to install LAMP stack on Ubuntu 20.04.

Step 1: Update Ubuntu 20.04

Before we start, it’s always a good idea to update your Ubuntu server to the latest version. To do this, run the following commands:

sudo apt update
sudo apt upgrade

Step 2: Install Apache

Apache is a popular open-source web server software that can be used to host websites. To install Apache on Ubuntu, run the following command:

sudo apt install apache2

After installation, you can check if Apache is running by opening a web browser and entering your server’s IP address. You should see the default Apache page.

Step 3: Install MySQL

MySQL is an open-source relational database management system that can be used to store and manage data for your web applications. To install MySQL on Ubuntu, run the following command:

sudo apt install mysql-server

During the installation, you will be prompted to set a root password for MySQL. Make sure to choose a strong password and remember it, as you will need it later.

Step 4: Install PHP

PHP is a popular programming language used for web development. To install PHP on Ubuntu, run the following command:

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

This command will install PHP, as well as the necessary modules to allow PHP to communicate with MySQL and Apache.

Step 5: Test the LAMP Stack

Once you have installed Apache, MySQL, and PHP, you can test the LAMP stack by creating a PHP file in the Apache document root directory. To do this, run the following command:

sudo nano /var/www/html/info.php

This will open a text editor. In the text editor, enter the following PHP code:

<?php
phpinfo();
?>

Save the file and exit the text editor.

Now, open a web browser and enter your server’s IP address followed by /info.php. For example, if your server’s IP address is 192.168.0.100, enter the following in your web browser:

http://192.168.0.100/info.php

You should see a page with information about your PHP installation. If you see this page, congratulations! You have successfully installed the LAMP stack on your Ubuntu server.

Conclusion

In this blog, we have shown you how to install LAMP stack on Ubuntu 20.04. By following these steps, you can have a fully functional web development stack that includes Apache, MySQL, and PHP.


 Buy Linux Dedicated Server

Popular Blog Posts