Linux Administrator

How to Install LAMP on Ubuntu

Linux, Apache, MySQL and PHP is a solution stack that is most commonly referred to using its acronym “LAMP“. It is an open source development platform for creating and managing web applications. Linux servers work as back-end operating system. Apache is the web server, MySQL is the database and PHP is the server-side scripting language.

Apache is a web server that runs on most Linux/UNIX based operating system as well as on Windows. It is free and open source HTTP web server. It is used to server static page and dynamic content. It runs on more than 67% of all web servers in the world. It is fast,reliable and secure server.

MySQL is the most popular open source relational database management system (RDBMS). MySQL has become the leading database choice web-based applications, Used by high profile web properties including Facebook, Youtube, Twitter, Yahoo! and many more.

PHP ( Hypertext Preprocessor) is a free and open source server-side scripting language. Which is used to generate dynamic web page. PHP contain HTML,Text and script blocks. When user request for a PHP page through web browser than PHP script execute on web server and display the requested result in browser.

A LAMP (Linux, Apache, MySQL, PHP) stack is a common web stack used for hosting web content.

In this artile I will show how to install LAMP on Ubuntu.

Install LAMP on Ubuntu

Follow the below steps to install LAMP on Ubuntu.

Step #1: Install Apache

Apache 2 is available as an Ubuntu package, therefore we can install it using below command.

# sudo apt-get install apache2

Now restart Apache

For Ubuntu 14.04
# sudo service apache2 restart
For Ubuntu 15.04
# sudo systemctl restart apache2

To make sure everything installed correctly we will now test Apache to ensure it is working properly or not.

http://localhost
Or
http://Server-IP

Step #2: Install PHP

Run the below command to install PHP and Apache PHP modules.

# sudo apt-get install python-software-properties
# sudo add-apt-repository ppa:ondrej/php5
# sudo apt-get update
# sudo apt-get install -y php5

Now verify installed PHP5 version using following command.

# php -v
PHP 5.5.28-1+deb.sury.org~trusty+1 (cli) (built: Aug 16 2015 09:30:05) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Step #3: Install MySQL

At long last introduce mysql-server bundles for MySQL database. Additionally introduce php5-mysql bundle to use MySQL support using php. Use following command to install it.

# sudo add-apt-repository -y ppa:ondrej/mysql-5.5
# sudo apt-get update
# sudo apt-get install mysql-server php5-mysql

After installing MySQL execute following command for initial settings of MySQL server.

# sudo mysql_secure_installation

Now restart Apache:

For Ubuntu 14.04
# sudo service mysql restart
For Ubuntu 15.04
# sudo systemctl restart mysql
Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

1 Comment

  • Assignment Details:
    To monitor servers using Sensu monitoring tool.
    You should be able to perform this assignment in AWS free tier. We would request to create personal AWS account as sharing account credentials with each one of you is not feasible for us.

    Task:
    Setup two instances – one with LEMP stack(LEMP-Server) and other with Sensu monitoring tool(Sensu-Server).
    You should monitor both instances with Sensu Dashboard on (Sensu-Server).

    As a part of assignment, you will need to do the following tasks:

    1. Create a VPC with two private and two public subnets
    2. Spin up two Servers instances (t2.micro)
    LEMP EC2: Setup a sample LEMP application on one instance. You can choose anything you want.
    Sensu EC2: Setup Sensu(Monitoring tool) on other instance (https://sensu.io/)
    3. Monitor below parameters on Sensu
    LEMP EC2 + Sensu EC2: Disk, Memory(RAM) and CPU
    LEMP EC2: Port 80, MySQL Process
    Sensu EC2: Sensu Process

    sir need your help to complete this assignment

Leave a Comment