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.
sudo apt update
sudo apt install apache2
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.
sudo apt install mysql-server mysql-client
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.
mysql -u root -p
and enter the MySQL password. This will run the MySQL command prompt, this means MySQL server is working perfectly.
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
sudo apt -y install php7.0 libapache2-mod-php7.0
Now you should install all the necessary package to work with php, mysql and apache.
sudo apt-get install php-mysql php-curl php-gd php-intl php-pear php-imagick php-imap php-mcrypt php-memcache php-pspell php-recode php-snmp php-tidy php-xmlrpc php7.0-xml php7.0-sqlite
We have done install LAMP. Now restart the apache to ensure its working.
sudo /etc/init.d/apache2 restart
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
sudo chmod 777 /var/www/html
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
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.
sudo apt-get install phpmyadmin
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
sudo nano /etc/apache2/apache2.conf
and add the following line.
and press Ctrl + X to save and restart the apache again.
sudo /etc/init.d/apache2 restart
Now navigate to http://localhost/phpmyadmin it will work perfectly.
And Finally LAMP is ready to use with your Elementary OS Loki.