Install LAMP Stack on Ubuntu 20.04

|
Last Updated:
|
|

Welcome to our guide on how to install LAMP Stack on Ubuntu 20.04. If you are looking at building some web application, LAMP stack is the first thing you might need. As you already know, LAMP is a group of opensource web development softwares; Linux OS, Apache http serverMariaDB/MySQL relational database management systems and PHP web scripting language.

Installing LAMP Stack on Ubuntu 20.04

As per the acronym, Linux system is the first component of LAMP stack. And since you are here, Ubuntu 20.04 is our first component of LAMP stack.

Run System Update

To begin with, update and upgrade your system packages;

apt update
apt upgrade

Install Apache Web Server on Ubuntu 20.04

Apache web server can be installed by running the command below;

apt install apache2

Once the installation is done, start and enable Apache to run on system boot.

systemctl enable --now apache2

If you going to be accessing Apache from your external system, then you need to allow it on firewall, that is, in case UFW is running;

ufw allow Apache

or simply run ufw allow 80/tcp to allow HTTP traffic.

Verify external access to Apache by navigating to your browser and entering the server IP address or hostname as http://Server.IP_or_hostname. You should land on Apache HTTP server test page.

Install Apache on Ubuntu 20.04

Great. Proceed to install MySQL/MariaDB on Ubuntu 20.04.

Install MySQL Database Server on Ubuntu 20.04

In this demo, we are running LAMP stack on Ubuntu 20.04 with MySQL 8. Therefore, follow the link below to install MySQL 8 on Ubuntu 20.04;

Install MySQL 8 on Ubuntu 20.04

Install PHP on Ubuntu 20.04

PHP is the last but not least component in LAMP Stack. In this demo, we are going to use PHP 7.4 for our LAMP stack. Follow the link below to learn how to install PHP 7.4 on Ubuntu 20.04;

Install PHP 7.4 on Ubuntu 20.04

Installing PHP Modules on Ubuntu 20.04

Installation of PHP installs with itself other PHP modules such as, libapache2-mod-php7.4, php-common, php7.4-cli, php7.4-common, php7.4-json, php7.4-opcache, php7.4-readline

Install MySQL module for PHP and any other module you may need for your web application.

apt install php7.4-mysql

Testing PHP Processing on Ubuntu 20.04

You can test PHP to confirm that is working as required as well check the version and installed modules using the simple PHP info script.

echo "<?php phpinfo(); ?>" > /var/www/html/info.php

Restart Apache

systemctl restart apache2

Next, navigate to the browser and enter the address, http://<server-IP>/info.php

PHP ubuntu 20.04

If you see this page, then PHP installation is working pretty well.

That marks the end of our guide on how to installing LAMP stack on Ubuntu 20.04.

Related Tutorials

Install LAMP Stack on CentOS 8

Install LAMP Stack with MariaDB 10 on Debian 10 Buster

Install LAMP Stack on Fedora 30

Install LAMP Stack on Debian 9

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment