Install LAMP Stack on Ubuntu 16.04 LTS

LAMP Stack is very popular open source web platform which is commonly used to run web servers. The word LAMP stands for Linux, Apache, Mysql and PHP or Perl or Python. And stack is the hierarchy of aforesaid. The base level holds Linux, then Apache & Mysql, then script like PHP/Perl/Python. It has a complete solution for development and deploys web applications. Most of the people like it because it is reliable, customizable and completely free.

As per Netcraft serves Its holds approx 33% market share which is leading the world. and most of the web application like WordPress, duple, Joomla etc. runs based on it.

Here I go to install LAMP Stack on my Ubuntu 16.04 LTS.

Step1 : Install Ubuntu 16.04 LTS

First of all, you have to install Ubuntu 16.04 LTS server on your system. If you haven’t click on the link to download ISO.

By default at the final stage of installation, it will ask which purpose your server will use to.  There is an option LAMP, you have to check it. And then Continue. It will automatically install LAMP into your server. Please see the picture. But rather default installation, manual installation is best practice for you. because you can install customized module as per your need.

LAMP Stack

If you haven’t at the time installation then you have to proceed with the manual installation.  Here I have a shell script that installs LAMP with the virtual host at the end of configuring Vhost tutorial. Click here to download the script

 Step2 : Update Ubuntu 16.04 LTS

$ sudo apt-get update
$ sudo apt-get upgrade

 Note: Do not use super user access if you are newbie and unless its necessary.

aptget-update

Step3 : Install Apache on Ubuntu 16.04 LTS

$ sudo apt-get install apache2

install-apache-server

After installing apache you can check whether its work or not by typing http:// 192.168.xxx.xxx  your server IP. The page should display the words “It works!” like this. In my case, the server IP is 192.168.182.50. You can find your Server IP using ifconfig command.

check-apache-server

Step4 : Install MySQL Server on Ubuntu 16.04 LTS

$ sudo apt-get install mysql-server php-mysql

install-mysql-server

During the installation of Mysql server, it will ask for the root password to Mysql user. Do not confuse with ubuntu root user and Mysql root user. Here you ask to set the password for MySql root user to access MySQL shell.

If you want to install PHPMyAdmin for MySQL follow this.(This is optional)

$ sudo apt-get install phpmyadmin

install-phpmyadmin

After installing phpmyadmin you can access MySQL administration over the browser. simply type your IP afterward /phpmydamin. Check it after installing PHP otherwise an error will occur. Do this after step 4.

phpmyadmin

Step4 : Install PHP and its Module on Ubuntu 16.04 LTS

$ sudo apt-get install php libapache2-mod-php php-gd php-mcrypt

install-php

There are various PHP modules you can install on your server as per your requirements. You can find the list of PHP module using following.

$ apt-cache search php

php-module

Step5 : Setup your web application and finalize.

After that, you have to add PHP to the directory index, to serve the relevant PHP index. Here I add index.php at the begin.

$ sudo nano /etc/apache2/mods-enabled/dir.conf
 GNU nano 2.5.3 File:               /etc/apache2/mods-enabled/dir.conf Modified

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

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


Press Ctrl+X then Y enter to save and exit.

Now its time to setup your web application. go to /var/www/html directory and copy your application. Here I made a test whether its works perfectly or not by making a file with name index.php then putting the following line.

$ sudo nano /var/www/html/index.php
<?php
phpinfo();
?>

Now Press Ctrl+X then Y enter to save and exit. and go to browser type your IP.

phpinfo

Conclusion

So Basically LAMP Stack is Linux and bundle of Open source software and modules that provide a reliable platform to the user to set up their web applications. The above setting used for a single web application if you want to run multiple web application then you have to configure the virtual host. In next article, I will discuss and setting up Vhost for multiple web applications on a single server. Thank you for reading this article hope it helpful to you.

 

The following two tabs change content below.

Subroto Mondal

Chief Coordinator HR&CR
I like Programming and New Technologies. And work with Linux.

One Pingback

Leave a Comment

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.