Ubuntu Linux is the most popular distribution of Linux. In this tutorial I will show you how to setup your own web server running LAMP (Linux, Apache, MySQL, PHP).

NOTE: I’m writing this guide assuming that you know how to setup and install Ubuntu Linux

Apache2 / PHP5 / MySQL

There are two ways you can install Apache, trough Synaptic Package Manager (System > Administration > Synaptic Package Manager) or using the apt-get command

Synaptic:

Simply go to Synaptic Package Manager and Search for Apache2, PHP5, mysql-server, mysql-client and phpmyadmin (if you choose)

right click each package and mark it for installation.

Then click apply and let it install, simple as that.

Apt-get:

Issue the following commands at the terminal (Applications > Accessories > Terminal)

sudo apt-get update
sudo apt-get install apache2 php5 mysql-server mysql-client

NOTE: I only included the php5 package, depending on your needs you will have to install additional packages, PHP will resolve the required dependencies. I also recommend installing the phpmyadmin package as well.

When prompted to install enter Y this will install Apache2, PHP5, mysql-server, mysql-client and their dependencies.

Testing the Apache server:

Once you have installed the Apache server you should test it by going to http://localhost/

The page should display

It Works!

Aditional Information:

If the page does not display when you go to local host try issuing the following command

sudo /etc/ini.d/apache2 restart

Also just FYI the document root for the web files is located at:

/var/www/