Install LAMP Stack on Ubuntu 20.04

LAMP Stack is web service software that stands for phrase Linux, Apache, MySQL, and PHP. In this article, we want to teach how to install Lamp Stack on Ubuntu 20.04. Follow the steps below to install the LAMP stack step by step.

Steps to install LAMP stack on Ubuntu 20.04

If you are connecting with a non-root user to your Linux, you should use the Sudo command first of all your commands. check this article about the Initial server setup with Ubuntu 20.04.

Step 1 – Install Apache Web Server and Adjust the Firewall

At this point, you must install Apache as a web server on your Ubuntu 20.04. To do this, you can follow the steps below:

Installing Apache on Ubuntu 20.04

• Update your cache with:

apt update

• Install Apache with:

apt install apache2

Adjust the Firewall on Ubuntu 20.04

To complete the installation of Apache for the LAMP stack on Ubuntu 20.04 you need to adjust the Firewall.

The default firewall configuration tool for Ubuntu is UFW. You can check that UFW has an application profile for Apache like so:

ufw app list

In your output, you see available applications. Then, run this command:

ufw app info "Apache Full"

To allow incoming HTTP and HTTPS traffic for this server, run the command below:

ufw allow "Apache Full"

To access your Ubuntu page you need your IP address. Use the following command to get your IP address:

curl -4 icanhazip.com

When you have your server’s IP address, enter it into your browser’s address bar:

http://your_server_ip

You’ll see the default Ubuntu Apache web page:

Apache2 default page Ubuntu

Step 2 – Installing MySQL on Ubuntu 20.04

At this point, you need MySQL to install the Lamp stack on Ubuntu 20.04.

MySQL, the most popular open-source SQL database management system, is developed, distributed, and supported by Oracle Corporation.

Use this command to install the software:

apt install mysql-server

When the installation is complete, run a simple security script with the following command:

mysql_secure_installation

This will ask if you want to configure the VALIDATE PASSWORD PLUGIN.
If you answer yes you should select a level of password and then enter your password.
It’s better to choose a strong password.

For the rest of the questions, press Y and hit the ENTER key at each prompt.
Test your MySQL by typing MySQL in your command line. Then type exit to exit from it.
Your MySQL server is now installed and secured.

Step 3 – Installing PHP on Ubuntu 20.04

At this point, To complete the installation of the LAMP stack on Ubuntu 20.04 you need to install PHP.

PHP is a widely used open-source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

Run the following command to install all packages and their dependencies:

apt install php libapache2-mod-php php-mysql

Restart your Apache with the following command:

systemctl restart apache2

Now your LAMP stack is installed and configured.

Conclusion

At this point, you have learned to Set up LAMP Stack which includes Apache as a web server, MySQL as a database management system, and PHP for the web development on Ubuntu 20.04. Hope you enjoy it.

For more articles about Ubuntu, you can follow the Ubuntu 20.04 tutorials on the Orcacore website.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!