Installing A Lamp Stack On Ubuntu Linux with Tasksel

Last modified: 
Friday, March 27th, 2015

Special Note (03/27/2015)

This entry is a bit old. It should still work, but I generally recommend everyone use Vagrant to manage their local LAMP stacks.


These are some basic instructions and notes on installing a LAMP stack on Ubuntu or Debian Linux.

Installation Using Tasksel

Perhaps the easiest method for installing a LAMP stack on Ubuntu/Debian is to use tasksel.

Install tasksel

sudo apt-get install tasksel

Install the LAMP stack

sudo tasksel install lamp-server

At the prompt you should provide a Mysql root user password.

Test the Basic Installation

In your web browser, navigate to http://localhost. You should see the following message:

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

Where the Web Sites Are

The default web directory is in /var/www . Any other sites you set up will go in /var/www/vhosts.

Testing PHP

The following procedure can be used to test the PHP installation:

cd /var/www
sudo touch info.php
sudo vim info.php # Or whatever editor you like

In the open editor add the following line and save the file.

Now go to http://localhost/info.php in your web browser. You should see the standard PHP Info page. If PHP is not working and instead asks you to download the page, reinstall libapache2-mod-php5.

How to Reinstall libapache2-mod-php5

First purge any existing copies with apt-get

sudo apt-get remove --purge libapache2-mod-php5

Now reinstall to library.

sudo apt-get install libapache2-mod-php5

Visit the test page http://localhost/info.php again. If it still isn't working, you may find more help here .

Secure Default Mysql User Accounts

If you set a password for the mysql root user during the initial installation, then you should be good. If not, log in to mysql and remove any access users who are anonymous, not originating from an approved host, or not using a password.

Add GD Lib support

The tasksel install may not have GD installed or enabled. If so, run the following to install it.

sudo apt-get install php5-gd
sudo /etc/init.d/apache2 restart

Enable Mod Rewrite

If you are doing any fancy URL rewriting, such as Drupal's Clean URL's feature, you will need to enable Mod Rewrite.

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart

Install Tomcat Server

Optionally add the Java Tomcat server and mod_jk.

sudo tasksel install tomcat-server
sudo apt-get install libapache2-mod-jk

The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.