AndyHat Consulting


Setting up a development Apache 2 web-server on Ubuntu 12.10 or 13.04

The most common type of web-server available is based on the LAMP (Linux, Apache, MySQL, PHP) bundle, so in this tutorial I will cover creating a web development server based on these components. Another common component is phpMyAdmin which is a web base MySQL administration tool so we are going to include it in our tutorial.

This tutorial guides you through installing Apache 2, MySQL 5, PHP 5 and phpMyAdmin for use as a development web-server on Ubuntu Linux. All these packages are available in the Ubuntu software centre at the versions we require.

To make a fully secure publicly available web-server it would require many other steps that aren’t always necessary when developing websites.

If you want to use the XAMPP installation instead please see my Installing XAMPP on Ubuntu tutorial.

Step 1 Updating the system

Open the terminal from the launcher or by pressing Ctrl-Alt-t.
Now before we stat installing anything you need to check for updates by typing:

sudo apt-get update

You should enter your password when prompted. If there are any updates found you should agree to update and let them install before continuing on with the installation.

Step 2 Installing the Apache 2 web server and PHP

Now that the system is up to date we can install the Apache 2 web server by typing

sudo apt-get install apache2

Next we will install PHP by typing

sudo apt-get install php5

If asked asked to confirm the installation press Y  or Enter to proceed with the installation.

As these instructions are for a development web-server we will now install the Xdebug PHP 5 debugging library (this can be skipped if you just want to host PHP websites)

sudo apt-get install php5-xdebug

Step 3 Installing the MySQL Database server

Now we need to install the MySQL Database server that we will be using to provide data for our websites by typing:

sudo apt-get install mysql-server

You may be asked to confirm the installation so press Y or Enter if needed to proceed with the installation.

You will be asked for a password for the root (administrator) user.


MySQL Password Prompt

MySQL Password Prompt

You will then be prompted to repaet the password that you jsut entered to confirm that it’s correct.

MySQL Password Confirmation

MySQL Password Confirmation

Now to allow PHP to work with MySQL we need to the php5-mysql package by typing:

sudo apt-get install php5-mysql

Step 4 Testing the Installation

Test the web-server installation in Firefox by typing localhost in the address bar.


Test Apache install

Apache test page.

Step 5 Installing the MySQL administration system (optional)

Th help use create, manage and delete MySQL databases we are goin to install the web based phpMyAdmin database administration system.

To install phpMyAdmin type the following in the terminal:

sudo apt-get install phpmyadmin

If asked asked to confirm the installation press Y  or Enter to proceed with the installation. Once downloaded you will be presented with a series of dialogs to configure phpMyAdmin with your database server and web server.

The first dialog asks what type of web server you are using. You will see a red box showing the highlighted option. The currently selected option will have beside it.

phpMyAdmin web-server selection

First phpMyAdmin set-up dialog to select the web-server type.


On the screen above make sure that the apache2 has the red highlight (use the arrow keys to select it if required) and press Space to select it (you will see a *) then press Enter.

The dialog will allow you to create the dbconfig-common database used by phpMyAdmin.

dbconfig-common set-up

Second phpMyAdmin set-up dialog to configure the database.

Make sure that the Yes option is highlighted and press Enter to configure the database.

The next dialog requests the database administrator password to create and manage databases. You need to type the password for the administrative (root) account for the database server then press Enter. The password will be obscured.

Database root password set-up

Third phpMyAdmin set-up dialog to enter the root database password.


For the next dialog you can safely select <OK> (by using the Tab key) then press Enter to generate a random database password for the phpmyadmin user.


phpMAdmin database password

Fourth phpMAdmin set-up dialog to configure the database password.

Next we will test the php, mysql and phpmyadmin installations by typing localhost/phpmyadmin in the Firefox address bar.


phpMyAdmin Test

Testing PHP, MySQL and phpMyAdmin

The user name is root and the password is the database server root password. If you can login then PHP, MySQL and phpMyAdmin are correctly installed.

 Final steps

To make the webserver usable we will need to set-up a websites folder, set-up virtual hosts and enable some required apache modules.

Installing XAMPP on Ubuntu 11.10 and 12.04

This tutorial has been written to help you install XAMPP on 32bit Ubuntu 11.10 or 12.04 Linux. First let me answer the question why install XAMPP rather than installing Apache, MYSQL and PHP from the Ubuntu repository. XAMPP gives you everything to run a test web server in a single portable package theoretically making it easy to copy the configuration between machines. XAMPP also gives you an easy way to only start the web server when required.

For production web servers and full time development machines it is better to use the Apache server from the Ubuntu repository. For a tutorial on setting up a full time web development machine please see my settting up Apache 2 server on Ubuntu tutorial.
These instructions are a combination and addition to those found on the Apache Friends (XAMPP) website and Upubuntu websites.

Step 1: Get XAMPP

Download XAMPP for Linux from Apache Friends. The next few steps 2 – 4 are the same as on the Apache friends website.

Step 2: Installing XAMPP

Go to a Linux shell (Ctrl-Alt_T), Change directory to the folder that XAMP was downloaded to.

cd ..\Downloads

Extract the downloaded archive file to /opt with root access:

sudo tar xvfz xampp-linux-1.7.7.tar.gz -C /opt

Any versions of XAMPP already installed in the opt folder will get overwritten by this command. Now XAMPP is now installed in the /opt/lampp directory.

Step 3: Start Apache

To start XAMPP simply call this command:

sudo /opt/lampp/lampp start

You should now see something like this on your screen:

Starting XAMPP 1.7.7...
LAMPP: Starting Apache...
LAMPP: Starting MySQL...
LAMPP started.
Ready. Apache and MySQL are running.

Step 4: Testing the installation

OK, now to check that everything really works? Just type in the following URL in web browser:


You will now see a screen like this asking you select your language.

XAMPP Language selection page

Click the language you want and you should now see the start page of XAMPP containing some links to check the status of the installed software and some small programming examples.

Main XAMMP Intstall hoome page

Step 5 Fix Security (optional)

To make the lampp installation more secure run the lampp security wizard to set passwords and follow the on screen prompts. In the terminal window type.

sudo /opt/lampp/lampp security

Step 6 Stop Lampp

To stop XAMPP type.

sudo /opt/lampp/lampp stop

Step 7 Add XAMPP to the Unity Dash

To make XAMPP more convenient to use you might want to add it the Ubuntu Dash. For this step you will need to have the Main Menu application installed which can be done using the Ubuntu Software Centre. First open the Ubuntu 12.04 Unity Dash and start the Main Menu application.

Loading Main Menu

You should get the main menu application loaded which will look something like this.

The Main Menu application

Select the category that you want XAMPP put in (Internet) and click the New Item button. This will display the “Launcher Properties” dialog as shown below.

New launcher properties

For the type make sure that Application is selected. The Command should be:

gksudo /opt/lampp/share/xampp-control-panel/xampp-control-panel

If you want to add an icon click on the icon in the top left corner. An XAMPP icon can be found at /opt/lampp/htdocs/xampp/img/logo-big.gif

You will now need to run Lampp from the Dash to add it to the Launcher.

Step 8 Set-up a folder in user account (Optional)

If you want you can add a folder to your home directory to contain websites you want to work with.

In the terminal make sure that you are in your home folder an then create a public_html folder with.

mkdir public_html

You now need to change the permissions on the new folder to allow websites to load correctly.

sudo chmod 777 -R public_html

The next step is to create a link to new public_html in your Home folder

cd /opt/lampp/htdocs
sudo ln -s /home/[username]/public_html ./[username]

Where [username] is you current user name.

Now to check that the new folder works. Place a test web page in the public_html folder in your Home directory then start XAMPP. Now just type in the following URL in web browser:


Where [username] is you current user name.

You should now see your test web page in the browser. Well done you now have a working installation of XAMPP.



Website check-list

As part of the “So you want a website” course I’ve been writing, I’ve created a simple Website check-list. It’s for anyone that is thinking of getting a website. The aim of the check list is to help you get the basic information that any web developer will need to know and to get you thinking of want you want from your new website. It covers everything from who you are and what you do to how the website should look and what it should do.

If you have problems with this check list then you need to go on my course to discover how to get the best from your web developer.

What is the internet?

This is a small presentation that I created while working as a tutor on the UKOnline Myguide course and I have also used in the “Using the Internet” at the Friends Centre.

Using the Internet course

I will be volunteering as a tutor for the new “Using the Internet” course run by the Friends Centre in Brighton. The course will run for 5 weeks from 6th May at their Ivory Place venue.

View Larger Map


Blog Archive