Setting up Ubuntu for Web Development

I’ve developed in the Windows environment for most of my career.  About 4-5 years ago I began to migrate to the Mac. Now my Mac is my primary computer.

I recently worked on a project where the target OS is linux, so I installed Ubuntu 9.04 desktop on an old PC. The following are the steps I took to create a web development box. This post assumes that you have already installed Ubuntu. Click here or here for installation instructions.

After you have installed ubuntu, you may want to select/download a theme for your box. Click Install Instructions to learn how to install gnome themes.

First, I will set up LAMP (Linux, Apache, MySQL, PHP) and phpMyAdmin. AMP is my default web development environment, regardless of OS.

Next, I will install Python, Django, PostgreSQL, phppgadmin, and pgAdmin (needed for my new project).  I will also install Aptana Studio and Java (need JRE to run Aptana). I have been using Aptana Studio on my Mac for over a year, and it has become my default development IDE.

Before installing the necessary files, run the Update Manager to ensure that Ubuntu is up to date (System->Administration->Update Manager).

Installing Apache

First you need to verify whether the Apache webserver is already installed. The easiest way is to open your browser and enter http:/localhost/ or If Apache is installed, an html page will display:

It works!

If it does not display, open Terminal (Applications->Accessories->Terminal).

You could install Apache separately by entering:

sudo apt-get install apache2

But, since we know that we want to install LAMP (Linux, Apache, MySQL, PHP), it is better to install the files all at once.

sudo apt-get install lamp-server^
  1. When prompted, confirm that you want to install the package.
  2. At the next prompt, change the password for the root user on your MySQL database.

After the installation is complete, test the web sever again.

Open your browser and enter http:/localhost/ or If Apache is installed, an html page will display:

It works!

Restarting Apache

Restart apache, open terminal and enter:

Sudo /etc/init.d/apache2 start

Testing PHP

Your web files are served from /var/www/.

So let’s create a file there. Open terminal and type:

gksudo gedit /var/www/pInfo.php

This will open an empty file named pInfo.php in the text editor.


<?php phpinfo(); ?>

Save the file and exit the text editor.

Now open your browser and navigate to http://locahost/pInfo.php/

You should see

Installing phpMyAdmin

Now, install phpMyAdmin. Open terminal and enter:

sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

During the installation, you will be asked create a password so that phpMyAdmin can talk to MySQL. If you leave it blank, a random password will be generated for you.

Check to see whether /etc/apache2/conf.d/phpmyadmin.conf exists? You can do this in the terminal or check via the file browser (Places->File System).

If the configuration file does not exits, check whether /etc/phpmyadmin/apache.conf exists?

If it does, create a symbolic link:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf

Now restart Apache:

sudo /etc/init.d/apache2 restart

To test your installation, open your browser and go to:

You should see a login screen

You should now be ready to create your php applications, but let’s do one more thing. As I stated earlier, you web server files are located at /var/www/, but this directory requires admin rights in order to create files. So we will create a symbolic link.

First, open file browser (Places->Home).

Create a folder named public_html.

Now open terminal and enter:

ln -s /var/www/ /home/les/public_html/

Replace ‘les’ with your username. Now you can create all of your web files in your public_html folder.

Installing Postgresql

First let’s install the Postgresql database. Open terminal and enter:

sudo apt-get install postgresql postgresql-client postgresql-contrib

Now type: psql

This command is used to enter interactive mode. You will receive an error:

psql: FATAL:  Ident authentication failed for user "les"

Obviously, the user will be your username. Enter:

su - postgres
createuser -P root

You will be prompted to enter your password and verify your password.

The new role will be superuser:

Shall the new role be a superuser? (y/n) y

Now exit:


You also may receive an error after typing: ‘psql’:

FATAL:  Ident authentication failed for user "postgres"

To fix this, open your file browser and open:



localhost all all ident sameuser


localhost all all md5

Save the file and restart postgresql:

sudo /etc/init.d/postgresql-8.3 restart

I’m going to install two apps to mange the database: phppgadmin and pgAdmin

Installing phpPgAdmin

sudo apt-get install phppgadmin

After installation, enter:

sudo ln -s /etc/phppgadmin/apache.conf /etc/apache2/sites-enabled/phppgadmin
sudo /etc/init.d/apache2 restart

To test your installation, open your browser and go to:


If you receive an error:

Error: Login disallowed for security reasons.

We need to edit the phppgadmin config file. Open terminal:

sudo gedit /usr/share/phppgadmin/conf/


$conf[‘extra_login_security’] = true;


$conf[‘extra_login_security’] = false;

Save/close the file and then reload apache:

sudo /etc/init.d/apache2 reload

Installing PgAdmin

sudo apt-get install pgadmin3

After installation is complete, you can access it by going to Applications->Programming->pgAdmin III.

Installing Python and DJango

I could install Python and Django separately, but it is quicker to install them together:

sudo apt-get install python-django

To test your python installation, enter:


Your prompt should change to: ‘>>>’.

Now type:

import django
print django.VERSION

If you do not receive an error and a version appears, your installation was successful. I’ll talk more about Django in later posts.

To exit python command line, type:


One more thing. While setting up a Django project, I was trying to connect to the database when I received the error:

Error: No module named psycopg

Open terminal (if it is not already open) and enter:

sudo apt-get install python-psycopg2

Aptana Studio

Now I am going to install Aptana Studio. Before we do, we need to install Java:

sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

To install Aptana, you need to go to the download page. Follow the instructions.

That’s it. Now start coding.

Be Sociable, Share!

Checkout My New Site - T-shirts For Geeks