How to Install LAMP on Elementary OS Loki

Hi, Geeks! Before we start install LAMP on Elementary OS Loki, let’s take a short description about ‘what is LAMP?’.

What is LAMP?

LAMP is a open source software bundle stands for Linux, Apache, MySQL, PHP (LAMP). LAMP is used to run web server locally or globally on Linux Distros.

Install LAMP on Elementary OS Loki

Many linux distros comes with pre-installed LAMP, but in Elementary OS it has to be installed manually. In this tutorial I’ll show you clean installation of LAMP in Elementary OS Loki.

Step 1: Install Apache 2

Apache is a widely used web server which runs 65% webservers in the world. It is an open source software and can be highly customized. Open the terminal and run following command.

This will install Apache2 on your linux. Alright now to check apache is installed open your browser and type http://localhost on url bar, this should open Apache2 Default Ubuntu Page.

Step 2: Install MySQL

Next step is to install MySQL. MySQL is an open source Database Management System, It is used to manage database server. To intall MySQL Server and MySQL Client run the following command on terminal.

During the installation it will ask to set up password for mysql. It is recommended to enter the password. If  you missed to set-up the password while installing you can set password later by running the following command

The prompt will ask to enter the current password. Enter the current password or press ‘Enter’ for none.

Now the prompt will ask to enter the New Password for MySQL. Go ahead and create the new password. On next step MySQL asks for new changes, so press ‘Y’ to all the options to implement the new changes.

To check MySQL is up and working type the following command on terminal.

and enter the MySQL password. This will run the MySQL command prompt, this means MySQL server is working perfectly.

Now type

this will show all the list of databases present in the MySQL. Alright if everything goes right move to next step to install PHP.

Step 3: Install PHP 7

To install PHP 7 type the following command in the terminal

Now you should install all the necessary package to work with php, mysql and apache.

We have done install LAMP. Now restart the apache to ensure its working.

Now we must give wiretable access to html where we are going to store all the php projects.

Type the following command in the terminal

The next step is to check php installation is working. To do that we must create a php file inside html folder.

Now type the following php code inside the file

Save the file by pressing Ctrl + X. To test the code open the browser and navigate to

http://localhost/test.php

The browser display’s the php info page, It means everything works right and your LAMP ready to go. The next step is a optional step to install phpmyadmin

Step 4: Install PHPMyAdmin (Optional)

PHPMyAdmin is a open source web application written in PHP, which is used to administer MySQL or MariaDB.

To install phpmyadmin start run following command in terminal.

While installing it will prompt to select web server, select the MySQL server.

On next step it will ask to enter the password for phpmyadmin. It is highly recommended to set-up the password for phpmyadmin so go on.

Now navigate to http://localhost/phpmyadmin and enter the username: root and your password to start working with phpmyadmin.

If the browser doesn’t show phpmyadmin login page, then you should continue with the followings

Go to the terminal and type

and add the following line.

and press Ctrl + X to save and restart the apache again.

Now navigate to http://localhost/phpmyadmin it will work perfectly.

And Finally LAMP is ready to use with your Elementary OS Loki.

18 Comments

  1. On the step 3, I won’t recommend give 777 permission on html. That is very dangerous. You should give 770. And you must put your user inside the group of www-data (apache2).

  2. o got premission error when i want to save changes on etc/apache2/apache2.conf to add phpmyadmin ? how i can fix this problem

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.