Install LAMP on Ubuntu

Install Linux Apache, MySQL, PHP (LAMP) stack on Ubuntu 14.04:

Introduction : A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and 
web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a 
MySQL database, and dynamic content is processed by PHP.

Since you are on Ubuntu, you already have Linux out of LAMP with you.  All you remain to install are Apache, MySQL and PHP to install.  Well here it is ..

Step One — Install Apache :
For our purposes, we can get started by typing these commands:

sudo apt-get update
sudo apt-get install apache2

You can do a spot check right away to verify that everything went as planned by visiting your server  :  http://localhost

Step Two — Install MySQL :
Now that we have our web server up and running, it is time to install MySQL.

This time, we'll also install some other "helper" packages that will assist us in getting our components to communicate with each other:

sudo apt-get install mysql-server php5-mysql

Note: In this case, you do not have to run sudo apt-get update prior to the command. This is because we recently ran it in the commands above to 
Install Apache. The package index on our computer should already be up-to-date.

When the installation is complete, we need to run some additional commands to get our MySQL environment set up securely.

First, we need to tell MySQL to create its database directory structure where it will store its information. 

sudo mysql_install_db

Afterwards, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit.

sudo mysql_secure_installation

Just FYI, If needed to Un-install MySQL for whatsoever reason just fire below Commands one by one :

sudo service mysql stop  #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.5
sudo apt-get purge mysql-client-core-5.5
sudo rm -rf /var/log/mysql
sudo rm -rf /etc/mysql

Step Three — Install PHP :
We can once again leverage the apt system to install our components. We're going to include some helper packages as well:

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

In most cases, we'll want to modify the way that Apache serves files when a directory is requested. Currently, if a user requests a directory from the 
server, Apache will first look for a file called index.html. We want to tell our web server to prefer PHP files, so we'll make Apache look for an index.php 
File first. To do this,

sudo nano /etc/apache2/mods-enabled/dir.conf
And bring “index.php” at the start of list.

Now,  

sudo service apache2 restart

Install PHP Modules
To see the available options for PHP modules and libraries : apt-cache search php5-

If, after researching, you decide you would like to install a package, you can do so by using the apt-get install command like we have been doing for our other software.

sudo apt-get install package1 package2 ...

Step Four — Test PHP Processing on your Web Server :
In Ubuntu 14.04, this directory is located at /var/www/html/. We can create the file at that location by typing:

sudo nano /var/www/html/info.php

This will open a blank file. We want to put the following text, which is valid PHP code, inside the file:

<?php
     phpinfo();
?>

When you are finished, save and close the file.  Now Check at http://localhost/info.php

Install phpMyAdmin 
The easiest way to install phpmyadmin is through apt-get : 

sudo apt-get install phpmyadmin apache2-utils

After the installation has completed, add phpmyadmin to the apache configuration.

sudo nano /etc/apache2/apache2.conf

Add the phpmyadmin config to the file. 

 Include /etc/phpmyadmin/apache.conf

Restart apache:  

sudo service apache2 restart

Note : 
To enable passwordless MySQL root login via phpMyAdmin  :  Edit File,  /etc/phpmyadmin/config.inc.php  and to Enable the option, uncomment or add  the following line :    

$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

Hope this collection help one of you guys !

Add new comment