$ sudo apt-get install lamp-server^ phpmyadmin

This one line command tells Ubuntu to install lamp-server and phpmyadmin ( ^ means using tasksel), lamp-server is a set of applications to fully install apache, MySQL and php and set it up.

This code does it all, then just follow the instructions:

  1. Confirm the download with yes.
  2. Setup the MySQL root password (if you have a public server it is a must), then you will be asked, if you want to configure Apache or Lighthttpd, I choose Apache.
  3. When you are prompted with:
  4. The phpmyadmin package must have a database installed and configured before it can be used. This can be optionally handled with dbconfig-common.
  5. Unless you know that it is not what you want to do, you should choose Yes.
  6. You will be then asked to set a phpmyadmin password with MySQL, leave it blank, a random password will be generated, it is a good security measure, you can not give up what you don’t know 🙂

And .. it’s done.

Entering http://localhost/phpmyadmin or http://your.public.ip.address/phpmyadmin should be working now and you must be able to log in entering your root credentials, user: root, password: root password you entered in second step.

Tested on Amazon EC2 t1.micro and m1.medium, on my home PC and others running Ubuntu Server 12.04 LTS.