Home How To How To Install LAMP Stack on Ubuntu Linux

How To Install LAMP Stack on Ubuntu Linux [2021]

  • Users can implement a simple procedure to Install LAMP Stack on Ubuntu Linux.
  • The LAMP Stack is an open-source framework, used by various content management platforms.
  • LAMP stands for Linux Apache MariaDB/MySQL PHP, you need to install such packages one by one.

Install LAMP Stack on Ubuntu

The installation process of LAMP on Ubuntu is quite straightforward. No matter if you are a novice user or a professional developer, you will only be required to implement simple commands on the Ubuntu Terminal to get the job done.

How Do I Install LAMP Stack on Ubuntu?

Page Contents


If you are willing to Install LAMP Stack in Ubuntu, you will be required to implement the following solutions sequentially. Because you have to go through certain procedures to make the LAMP Stack web server work properly on your operating system.

Getting Started

First of all, users need to ensure that Ubuntu OS is updated to the latest version. For that, they need to acquire the services of the Ubuntu Terminal.

To launch this built-in utility, press Ctrl + Alt + T keys from the keyboard simultaneously. Else, launch the Terminal from the App Drawer.

Now run the following commands in the Terminal to update Ubuntu:

sudo apt update
sudo apt dist-upgrade
sudo apt autoremove

After the OS has been updated to the latest version, restart your computer to imply the previously made changes.

Installing Apache on Ubuntu

The installation of Apache on Ubuntu is quite nesscary. That’s why Apache is available in the Ubuntu repo store. So all you need to do is update the available packages and install the perspective repository by implying the given workarounds in the Terminal.

sudo apt update
sudo apt install apache2

Once Apache is installed on your system, you can enable/stop/start it at any instance. According to your desired mood, use one of the following commands to get the job done.

sudo systemctl enable apache2
sudo systemctl start apache2
sudo systemctl stop apache2

You can also check the status of Apache through your web browser. Simply, visit http://localhost/ on the web browser to view Apache welcome webpage.

Install LAMP Stack in Ubuntu

Installing MariaDB on Ubuntu

Both MariaDB and MySQL are open-source, they work in similar ways. But I would recommend you to use MariaDB, as it contains more storage engines as compared to MySQL. It also supports more than 200,000 connection pools. So rather than using any old database firmware, you should always prefer the futuristic one.

To update and install MariaDB on Ubuntu, run the following commands:

sudo apt update
sudo apt install mariadb-server

Now check the status of MariaDB:

sudo systemctl status mariadb

Users can perform some workarounds to secure their databases. A singular command can help achieve such a goal:

sudo mysql_secure_installation

The MySQL and MariaDB use auth_socket authentication protocol to help users launch the installed database firmware. So that you don’t have to enter a password, each time you are trying to connect from localhost using Unix socket file.

Simply, run the following command to perform MariaDB login:

sudo mysql

Installing PHP on Ubuntu

With Apache install on Ubuntu Linux, you would always prefer to use PHP. It works great with Apache and other famous web servers.

You can install PHP on Ubuntu using Apache web server by executing the following commands:

sudo apt update
sudo apt install php libapache2-mod-php

Occasionally, Ubuntu doesn’t contain the latest version of PHP in its repository store. In that case, you need to install a third-party repository to install the latest version of PHP on Ubuntu Linux.

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Once the PPA repo is added to Ubuntu, you can implement a singular command to install PHP’s latest version:

sudo apt install php8.0 php8.0-common php8.0-cli php8.0-gd php8.0-curl php8.0-mysql

Finally, the installation of LAMP is completed, and you can start to benefit from it.

That’s all, thanks for your time spent reading How to Install LAMP on Ubuntu Linux at it’sDailyTech.

A How-To expert, who's keen to help those who are unable to make the most out of their electronic devices. Especially the ones who don't want everything to be served on a plate.


Please enter your comment!
Please enter your name here