How To Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu Operating System

LAMP (Linux, Apache, MySQL, PHP) is an open source Web development platform that uses Linux, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language.
  • Linux: Linux is a operating system assembled under the model of free and open source software development.
  • Apache: Apache HTTP Server has been the most popular web server on the public Internet
  • MySQL: MySQL is original role as the LAMP’s relational database management system (RDBMS).
  • PHP: PHP is a server-side scripting language designed for web development and create build dynamic webpages. PHP code is interpreted by a web server via a PHP processor module, which generates the resulting web page.

Step 1: Installing Apache 2

It provides a full range of web server features including CGI, SSL and virtual domains. Open the terminal and type commands:
  sudo apt-get update
  sudo apt-get install apache2
It requires a restart for it to work:
  sudo /etc/init.d/apache2 restart
  {OR}
  sudo service apache2 restart
Open your browser and type: (eg. http://127.0.0.1).
How to Find your Server’s IP address
You can run command this command.
  ifconfig eth0 | grep inet | awk '{ print $2 }'

Step 2: Installing MYSQL with PHP 5

Open terminal and type in these commands:
  sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
During installation, you will be asked to setup the MySQL “root” user password. Enter the password and click Ok. Once you have installed MySQL, we should activate it with this command:
  sudo mysql_install_db
Also, you set manually password manually use thsi command:
  sudo /usr/bin/mysql_secure_installation
The prompt will ask you for your current root password. Type it in:
  Enter current password for root (enter for none):
  OK, successfully used password, moving on...
Prompt will ask you if you want to change the root password.
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y                                            
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...

Step 3: Installing PHP 5

Open terminal and type in this command.
  sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
LAMP is installed, creating a quick php info page
sudo nano /var/www/test.php
Add in following line:

Then Save and Exit.
Restart apache:
  sudo service apache2 restart