How to Install LAMP on Ubuntu 14.04 & 15.04

LAMP stack is nothing but a combination of opensource software’s to make a web server . A LAMP (Linux, Apache, MySQL, PHP) stack is a common web stack used for hosting web content. This tutorial shows how you can install an Apache2 web server on an Ubuntu server with PHP5 support (mod_php) and MySQL support.
Install lamp

Install Apache

Apache 2 is available as an Ubuntu package, therefore we can install it like this:

# sudo apt-get install apache2

Then 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

Install PHP

We can install PHP and the Apache PHP module as follows:

# 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

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

Then restart Apache:

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

Enjoy it!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.