Install LAMP Server on Ubuntu 20.04

I have written some Ubuntu Tutorials on this website. Today, I am going to add the collection with the new tutorial how to install LAMP Server on Ubuntu 20.04. LAMP stands for Linux, Apache, MySQL and PHP. Its a popular way to build a powerful website and web applications. I will try to explain every steps to get your web server up and running on Ubuntu 20.04. You can use the desktop version or the server edition of Ubuntu 20.04. On this tutorial, I am using the Ubuntu 20.04 server edition.

Steps to Install LAMP Server on Ubuntu 20.04

Step 1. Update Software

Before we jump into the installation, we need to make sure our software is up to date. Connect to your Ubuntu 20.04 directly or via SSH.

sudo apt update
sudo apt upgrade

Step 2. Install Apache

Apache is a popular web server. We can install Apache on Ubuntu 20.04 with this command

sudo apt install -y apache2 apache2-utils

After the installation is complete, we need to run the web server and enable it on startup

sudo systemctl start apache2
sudo systemctl enable apache2

Check the Apache status

sudo systemctl status apache2

You should see something like this

Make sure you got the status Active (running). At this point, we have successfully installed the Apache web server on Ubuntu 20.04. To test, open your web browser and then type the IP address of the Ubuntu 20.04 server. You will see the Apache2 Ubuntu Default Page as follow

Step 2. Install MariaDb Database

In this section, we are going to install MariaDb on Ubuntu 20.04. Use this command to install

sudo apt install mariadb-server mariadb-client

Now let’s check the status

sudo systemctl status mariadb

Make sure the Mariadb server is running during startup

sudo systemctl enable mariadb

Now, let’s run the post installation script

sudo mysql_secure_installation

You will need to create a new password for MySQL root user. The default password is none, simply press Enter to continue and then create a new password.

Done.

Step 3. Install PHP

Lastly, we are going to install PHP. The latest version of PHP when this article is written is PHP version 7.4. You can install PHP and its dependencies with this command

sudo apt install php

Now verify the PHP installation. Create a new file called info.php and put it inside /var/www/html/ directory.

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

Now paste this line

<?php phpinfo(); ?>

Now open the web browser and type the IP address of the server and point to the info.php file. For example: 192.168.100.99/info.php

OK so at this point, we have successfully installed the LAMP Stack on Ubuntu 20.04 Server or Desktop edition. Thanks for reading and see you next time.

Be the first to comment

Leave a Reply

Your email address will not be published.


*