Install Apache2,PHP,Mysql,phpMyAdmin on Ubuntu 11.04+ (LAMP Server)

Make sure you have root user privilege. If not, append sudo before every command.

-Run apt-get update before proceedingThis is important !

Step One – Install Apache2 

  • apt-get install apache2

- Press ‘Y’ on prompt during installation.

Check your installtion via browser and type in your Domain Name/IP address/FQDN. It should look like below image.

apache success page

Step Two – Install MySQL

  • apt-get install mysql-server mysql-client

- Press ‘Y’ on prompt during installation. There are chances that you may not see below prompts.

-Enter password for MySql “root” user. You should see something like below image.

MySql Password Prompt

-Re type your password for confirmation.

There are chances that you may end up with following error.

E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

For above issue, run apt-get update. Then again apt-get install mysql-server mysql-client . 

Step Three – Install PHP

  • apt-get install php5

Step Four – Test PHP

  • vi /var/www/info.php

-Copy/Paste this line into the info.php file:

<?php phpinfo(); ?>

Point web browser to  http://your_ip_or_domain_name/info.php


Wait, there’s something remaining.

Step Five – Getting MySql support in PHP5

  • apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

- Press ‘Y’ on prompt during installation.

Restart Apache – /etc/init.d/apache2 restart or service apache2 restart

Step Six – Install phpMyAdmin

  • apt-get install phpmyadmin

- Press ‘Y’ on prompt during installation.

-Select ‘apache2′ by pressing Spacebar and then hit Tab->Enter to press Ok.


-Select ‘No‘ on next prompt

Configuring phpMyAdmin

Test phpMyAdmin - http://your_ip_or_domain_name/phpmyadmin

Pheeww ! Finally you are done with LAMP Server.


*There’s another easier way to install LAMP server, which personally I would not recommend. If you are a developer you would know why.

Type “ tasksel ” in your terminal (without quotes)

and you will get the below screen


Make sure

[*] Basic Ubuntu server
[*] OpenSSH server
[*] LAMP server

are selected, if not then select manually. Go ahead. Press Ok

You will be prompt for mysql password as in above process. You have to install phpmyadmin manually if you follow this way.