This will be a tutorial for setting up your own LAMP stack on Debian 7 Wheezy but this might also work for Ubuntu but is not guaranted.

What Is LAMP?

LAMP is an acronym for a software bundle that is Linux, Apache, MySQL & PHP. There are already available installer for this software stack like XAMPP which can be easily installed but if you want to setup your own LAMP stack using Debian aptitude then please read on.


Ill assume you have already installed Debian 7 Wheezy and is already ready for setting up your LAMP stack. Login as root in your terminal by typing su or you can use sudo if you have installed it earlier.

Update/Upgrade Packages

To make sure that your system is up to date just type in the command below in your terminal.

 apt-get update
 apt-get upgrade

Install MySQL

Install MySQL by typing this in terminal

apt-get install mysql-server

it should ask you a root password like the image below.

This root password is different from your Debian root password and this will only be used for MySQL access. You can either leave it blank for now but make sure to add a password later specially if you are going to allow remote connection.

Install Apache

After installing MySQL next we need to install Apache, to install type this in your terminal

apt-get install apache2

after installing make sure that Apache is running by going into your browser and typing in “localhost” in the address bar. If the installation was successful you should see something like this in your browser

Install PHP

Aside from installing php we will also need to install the apache mod for php and a mysql connector for php. To install them type in your terminal

apt-get install php5 libapache2-mod-php5 php5-mysql

Make sure that libapache2-mod is enabled by typing this

a2enmod php5

Check If Everything Works

To check if everything works properly we will make Apache serve a php file with echo ofphpinfo().

Check Where The DocumentRoot Is Located

First check where the public root of the default VirtualHost of Apache resides. This is usually located in /var/www. To check you will need to open the config file for the default VirtualHost in /etc/apache2/sites-enabled/000-default by typing this

nano /etc/apache2/sites-enabled/000-default

Locate the line with a DocumentRoot directive. It will look something like this

DocumentRoot /var/www

where /var/www is the location of the DocumentRoot.

Create The PHP Test File

Since we now know the location of DocumentRoot and it is located in /var/www. Create a php file there named php-info.php by typing

nano /var/www/php-info.php

and put this inside:

 echo phpinfo();

Save it by pressing ctrl+o and exit by ctrl+x. After saving the php-info.php file type this into your browser address bar:


If everything was installed correctly you should see something like this:

To check if MySQL is now supported find the part for mysql it should look like this

Thats it, now you have a working setup of a LAMP stack.

Looking for cool VPS provider? Try Linode(referral link), they are currently my VPS provider.