What is LAMP and How to install it on Ubuntu Server?


LAMP stands for Linux, Apache, MySQL, and PHP. So it’s a group of software that can be installed on a Linux server to host a web app or a website dynamically. It is widely used in case of setting up a WordPress site.

Here, you can learn how to install and setup LAMP on your Ubuntu server.

Apache Installation:

Apache is a well-known web server which makes it perfect to use in a web development stack. It is very simple to install Apache on an Ubuntu server. Just apt package manager to install it.

 $ sudo apt update
 $ sudo apt install apache2 

After that, please ensure if it’s working by

$ sudo systemctl status apache2

If it’s now active yet then start this with

$ sudo systemctl start apache2

and then it will work fine.

Check Apache default page at http://your_server_ip_Address


MySQL Installation

In this stack, MySQL will be going to use. MySQL is a very popular and open-source Database Management System. It will be used to store the data about your website or web application. It is a quick installation of MySQL, to understand all these steps you can refer here.

Again, we will use apt package to install MySQL.

$ sudo apt install mysql-server

Now to login with the password in MySQL, we will install the secure script of MySQL.

$ sudo mysql_secure_installation

This will install a security plugin in MySQL for password-based login.

First login with this command:

$ sudo mysql

Now, check all the users present and their plugins.

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;

Set password for root user.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Flush privileges.


Check again the authentication plugin for all users.

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;

The root user has its password.

mysql> exit;

MySQL is successfully installed on your server.

PHP Installation

For code, we have PHP language which will process the code to display the content. All the functions and scripts can be executed in this.

We can install it with the apt package.

$ sudo apt install php libapache2-mod-php php-mysql

This will easily install PHP on your server without any issue.

In this cas,e a project code has an index.php file, so, we need to change the priority of index files set in the Apache webserver. To change the priority, we can need to edit in dir.conf file of Apache.

$ sudo nano /etc/apache2/mods-enabled/dir.conf

It will look like this:

 <IfModule mod_dir.c>
     DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

Now move the index.php at the beginning and the update file will look like this:

 <IfModule mod_dir.c>
     DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

Save the file and restart the Apache.

$ sudo systemctl restart apache2

Check the status.

$ sudo systemctl status apache2


Now, Lamp is installed on your system which opens several options to use this environment for. This is like a platform which allows you to install web-related application and software on your server. The best example is WordPress setup on an Ubuntu server.

One thought on “What is LAMP and How to install it on Ubuntu Server?

Leave a Reply

Your email address will not be published. Required fields are marked *