Verified and Tested 09/05/15

Introduction

In this How-To, we will walk you through installing LAMP on your  Debian 8.2 Cloud Server. LAMP is simply a software bundle that consists of 4 components. Linux is the base of the platform; all components are installed within the Linux environment. In this case, we will be using Debian 8.2 for the Linux OS. Apache will be used for the web service. MySQL will be used for database management,  and  PHP will be as the programming language. Altogether this forms LAMP, which is also called a LAMP Stack.

LAMP Illustration by Walker Cahall http://www.waltronic.net/ LAMP Illustration by Walker Cahall

Prerequisites

A server with Debian 8.2 installed. If you do not have a server already, you can spin up a virtual private server in under 30 seconds.

Installing LAMP on Debian 8.2

We will first start by installing Apache. Apache is an open source web server and is the most popular web server in the world.

Installing Apache on Debian 8.2

Install Apache with the following command to begin the install:

apt-get install apache2

Verify if all is working by opening your browser and going to http://youripaddress

If you are unsure what your IP address is, run the following:

ifconfig

An example of ifconfig showing the IP of 192.68.0.2 An example of ifconfig showing the IP of 192.68.0.2In our example, we would put http://192.68.0.2 in the address bar and get the following page:

Installing Linux, Apache, MySQL, PHP (LAMP) On Debian 8 On A Cloud Server Or VPS 04 An Example of the default Apache page on Debian 8

Installing MySQL on Debian 8.2

Install MySQL with the following command:

sudo apt-get install mysql-server php5-mysql

During the install, it will prompt you to enter a MySQL root password. Set any password that you would like.

Installing Linux, Apache, MySQL, PHP (LAMP) On Debian 8 On A Cloud Server Or VPS02 An example of the setting the MySQL password during install.Secure MySQL from the default settings with the following command:

mysql_secure_installation

Note: You will be prompted with a series of questions. Simply type N for the change root password and Y for yes on all of them, see the screen shot below:

Installing Linux, Apache, MySQL, PHP (LAMP) On Debian 8 On A Cloud Server Or VPS 03 An example of the questions during mysql_secure_installation

Installing PHP on Debian 8.2

Install PHP with the following command to begin the install:

apt-get install php5

Create a test PHP file in the following directory with the following command:

nano /var/www/html/info.php

Insert the following code in the empty space then save and exit:

<?php
phpinfo();
?>

Restart Apache so all the changes take effect:

service apache2 restart

Test your page in your browser with the following hyperlink changed with your IP address:

http://youripaddress/info.php

Installing Linux, Apache, MySQL, PHP (LAMP) On Debian 8 On A Cloud Server Or VPS 05 An example of the php.info file that was created on Debian 8.2Congratulations! You have just installed LAMP on your Debian 8 Server. Thank you for following along in this How-To, please check back for more updates or take a look at our Installing WordPress on Debian 8 How-To!