Installing a LAMP server on Ubuntu Desktop 12.04

So I am developing PHP code and my OS of choice for my workstation is Ubuntu Desktop. Currently, I am running the Long Term Support version 12.04. To develop and test my code I need a LAMP server. There are two ways to go about installing a LAMP development server:

  1. Install XAMPP for Linux from
  2. Install AMP as you already got the L for Linux!
In my view, XAMPP is really only suitable for development environments, although it is possible to make it a secure installation. Still, it will always be an Apache distro running on top of an OS and the integration with the OS can only go so far. And that is also how it was intended: as an easy and quick solution for development.

Installing AMP on the Ubuntu Desktop is like having a real LAMP server only with the overhead of the Desktop.

I have used XAMPP for Linux as I was just starting out running code locally. It is a pretty safe solution as it will not interfere with your OS. Just unzip and start as per the instructions found here. Then you can hack your way around. And if you messed up your installation just delete it and reinstall it.

But now I wanted a real LAMP install and found out this is actually very easy to do on Ubuntu Desktop. I couldn't imagine otherwise anyway. Like almost anything on Debian based OS-es, it is only a few commands and apt-gets away.

So here is what I did to get a LAMP server up and running on my Ubuntu Desktop workstation ready for development:

Open the terminal using ctrl + alt + t and type (don't forget the carrot ^):
sudo apt-get install lamp-server^
Type in your admin/root password and follow the instructions. It's pretty straight forward. All needed components will be downloaded and installed and you will be prompted to configure passwords for MYSQL and all.

Then to easily setup databases I like to use PHPMyAdmin, so I go ahead and type:
sudo apt-get install phpmyadmin
Same thing here: just follow the instructions and you'll be done in a jiffy.

And that's basically it.
However, I wanted to use a folder in my home directory as the working folder for all my scripts. The standard root folder for the webserver is /var/www for which I need root access to be able to edit any files. One solution could have been to install Proftp, set it up and ftp into that directory. I took another route and that was to set up a site that has the folder /home/davetromp/Lamp (my desired working folder) as the site document root.

This is how I set that up:

In the terminal I changed dir to the apache2 sites folder:
cd /etc/apache2/sites-available

Then I copied the default site file to a new site called davetromp:
sudo cp default davetromp

Then I edited the site config file:
sudo nano davetromp
Like this:

Then I activate the new site:
sudo a2ensite davetromp

And added it to the hosts:
sudo nano /etc/hosts
I just added davetromp behind localhost so it looked like this:       localhost davetromp
Finally reload the apache server:
sudo /etc/init.d/apache2 reload

Now I put a test HTML file in my working dir and browsed to http://davetromp and voila it worked.

Later as I was working with PHP files I noticed errors were not being displayed, which is not handy for writing code. So I changed some settings in the php.ini file. This can be done like so:
cd /etc/php5/apache2
sudo nano ./php.ini
In the php.ini file I made sure that the display_errors = on and that error_reporting = E_ALL & ~E_DEPRECATED


Popular post

Which Forex Pairs are Generally Trending and Which Ones Tend to Revert to the Mean

Build more wealth with gold

Get links to data referenced by