In that article, I will give you a complete guide to setup LAMP Stack on your local machine.
A LAMP Stack is the software stack of Linux Operating System, Apache HTTP Server, MySQL Relational Database Management System, and PHP Programming Language(LAMP) which is the foundation for the Linux hosted Websites and Web Applications. Now, I will show you How to install LAMP Stack on Ubuntu 20.04 LTS.
Install LAMP Stack on Ubuntu 20.04 LTS
Here are the minimum system requirements to install and run LAMP stack in Ubuntu 20.04 LTS.
RAM: Minimum 1GB memory
HDD: At least 1 GB Free Disk Space
CPU: 1 Core Processor
The layer of LAMP Stack consists of free and open-source products i.e. Linux, Apache, MySQL, and PHP. There are several variants of this model as well. There is also much alternative software replacing the LAMP Stack. Some examples of those alternatives are:
XAMPP : Operating System, Apache, MySQL & PHP
WAMP : Windows, Apache, MySQL & PHP
WISA : Windows, IIS, SQL & ASP.net
MAMP : Mac OS, Apache, MySQL & PHP
To Install LAMP Stack on your system follow these steps:
Step 1: Updating and upgrading your System
First of all, we will update the package database of packages needed for the system using the following command which requires superuser privileges, so you’ll need to use sudo:
$ sudo apt-get update
then, we will fetch the new version of packages existing on the machine using the following command:
$ sudo apt-get upgrade
Step 2: Install Apache Server
After our system is upgraded to the latest packages, we will now install the Apache Server in our system. To install the Apache package in Ubunutu, use the command:
$ sudo apt-get install apache2
now, verify that the Apache server was installed correctly, open the web browser and hit the following URL in the address bar:
Apache Server Controls:
To have control over the Apache server in the system, systemctl commands can be used with a series if switches:
Stop Apache Server:
$ sudo systemctl stop apache2.service
Start Apache Server:
$ sudo systemctl start apache2.service
Restart Apache Server:
$ sudo systemctl restart apache2.service
Reload Apache Server:
$ sudo systemctl reload apache2.service
Step 3: Install MySQL
To install MySQL by using the Ubuntu Operating System package manager use the command:
$ sudo apt-get install mysql-client mysql-server mysql-common
Start the MySQL Service:
$ sudo systemctl start mysql
To start the mysql shell for the first time run the following command:
$ mysql -u root -p
When you are prompted to enter the password, enter that one you set at the time of installation or if you haven’t set one, press Enter to submit no password. Then the following mysql shell should appear:
Set the root password
Now, if you are logged in by entering a blank password or if you wish to change the current root password that you set, you can change or create it by following commands:
*For MYSQL 5.7 or earlier, enter the following commands in mysql shell and replace the newpassword with your new password.
mysql> UPDATE mysql.user SET Password = PASSWORD('newpassword') WHERE User = 'root';
*For MYSQL 5.7 or later, enter the following commands in mysql shell and replace the newpassword with your new password.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
To make the change take effect, use the following command:
mysql> FLUSH PRIVILEGES;
Launch on reboot:
$ sudo systemctl enable mysql
Step 4: Install PHP (PHP7.4 latest version of PHP)
TO install PHP and Apache PHP module on our Apache server run the following command:
$ sudo apt-get install php libapache2-mod-php
Once the packages are installed restart the Apache service using the command:
$ sudo systemctl restart apache2
To verify the installation, run the following command which will show the PHP Version
$ php -v
Step 5: Install phpMyAdmin (For Database)
Using the Ubuntu Package Manager phpMyAdmin can be installed by using the command:
$ sudo apt-get install phpmyadmin
Once the installation is finished restart the webserver.
To verify the installation type the following URL in web browser:
Hurray!! Congratulations, I hope you have learned the method on How to Install LAMP Stack on Ubuntu 20.04 LTS Focal Fossa. If you have any questions, suggestions, feedback please don’t hesitate to write them in the comment box below because it will help us to improve or correct our contents. Thanks, Happy FOSS Computing.
Ananta Mishra is a frontend developer and a creative graphics designer with experience in several designing platforms. He likes to be involved at different stages of a digital project, from the seed of the idea, through to sketches, design, and even the front-end and WordPress build.