Installing LAMP (Apache/MySQL/PHP) stack on Ubuntu

LAMP or Linux, Apache, MySQL, and PHP is the default software stack most PHP+MySQL based applications use, it's the easiest and quickest way to get your PHP+MySQL application online. A LAMP stack can be installed on your Ubuntu install with the following commands.

Updating the system

We first update the system to make sure that all our installed packages are upto date. Your Ubuntu system can be updated easily with the following command,

apt-get update && apt-get upgrade

Install Apache

Apache can be installed with the following command, usually Apache comes pre-installed on the default Ubuntu images we have but if your VPS has been installed with a minimal OS image, then it won't come with Apache pre-installed.

apt-get install apache2

Once the install finishes, start Apache with the following command,

service apache2 start

Install PHP

Here we install PHP and the PHP-mysql plugin for PHP to communicate with your MySQL server.

apt-get install php5 php5-mysql

Restart Apache so that Apache detects PHP and enables it,

service apache2 restart

Install MySQL

MySQL can be installed with the following command,

apt-get install mysql-server

Setup MySQL with a root password


Start MySQL once the above step is complete,

service mysql start

Set Apache/MySQL services to start on boot

chkconfig apache2 on
chkconfig mysql on

Done! Load your VPSes IP address in the browser and it should display the default Apache page!

All your files to be displayed go into the default web-root at


Last modified: March 01 2017 15:39:03