How to Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu

LAMP stands for Linux, Apache, MySQL, and PHP, is an open source software stack. LAMP is used to configure the web server and host the web content. This step-by-step tutorial shows how to install Linux, Apache, MySQL, and PHP on Ubuntu. Linux part is taken care of by Ubuntu, you only need to install the rest.

Follow the below steps to setup LAMP and install Apache, MySQL, and PHP on Ubuntu 14.04.

Step 1: Install Apache

Apache is the world’s most used open-source web server software. To install Apache on Ubuntu, open the terminal and type the following commands.

sudo apt-get update
sudo apt-get install apache2

Step 2: Install MySQL

MySQL is an open-source relational database management system. To install MySQL on Ubuntu, open the terminal and type the following commands.

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Step 3: Install PHP

PHP is an open-source server-side scripting language. To install PHP on Ubuntu, open the terminal and type the following commands.

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

Congratulation! Now you completed the installation of LAMP stack on Ubuntu.

Step 4: Restart Server

Apache will automatically restart after the installation of both PHP and MySQL. However, you can restart the Apache server manually by executing the following commands.

sudo service apache2 restart

Step 5: Check Apache

Open your browser and run this URL – http://localhost/. You’ll see a message saying “It works!”.Step 6:

Step 6: Check PHP

Now check whether PHP is working.
Create a new PHP file (info.php) in the /var/www/ directory and place the following code. Save the file.

<?php
phpinfo
();
?>

Open the http://localhost/info.php URL on the browser. If PHP info is displayed on the screen, PHP is working perfectly.

Do you want to get implementation help, or enhance the functionality of this script? Click here to Submit Service Request

Leave a reply

keyboard_double_arrow_up