Apache
sudo apt-get install apache2
PHP
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
MySQL
To install the MySQL Server and Client packages.
sudo apt-get install mysql-server mysql-client
This will install the mysql server and client packages.
By default, recent Ubuntu/Debian systems install a MySQL Server from the 5-branch.
Set MySQL Root Password
By default, the root account of the MySQL Server is empty. To set the mysql root password do the following.
sudo mysqladmin -u root -h localhost password ‘mypassword’ #replace the ‘mypassword’ with your password.
Connect to MySQL from PHP / Ruby
Now you have Apache+PHP already installed, and want to connect to MySQL from PHP scritps.
For that you have to install one library, which is used to connect to mysql from PHP. Use this command to install the library.
sudo apt-get install php5-mysql
In case you are using Ruby, use the command
sudo apt-get install libmysql-ruby to connect to MySQL from Ruby.
Note : while restarting the apache if you get the following error
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
then open the /etc/apache2/apache2.conf file and add the following line
as the last line
ServerName “YourSitename or Servername”
save the file and restart the apache by giving the /etc/init.d/apache2 restart command, you will not get the error anymore.
To Install MySQL Query Browser, an GUI for MySQL
sudo apt-get install mysql-query-browser
After installation, to start MySQL Query Browser go to Applications > Programming > MySQL Query Browser.
Install PHP-GD Library
The GD Graphics Library is useful for dynamically creating, manipulating images. You will need to compile PHP with the GD library of image functions for this to work. However Ubuntu (and Debian) comes with package called php5-gd
To install GD for PHP use the following command.
sudo apt-get install php5-gd
I’ve collected the information from net which are required while installing and configuring Apache, PHP, MySQL and given here. Hope this will help for somebody who can get all information at one place.

hey superb! could do everything so easily! Thanks for the compilation efforts!
great kumar
thanks
With the advent of 9.10, the easy (and I must say preferred) method to install LAMP is to use the tasksel command and choose to install a LAMP server. You can see how to over at my crib notes at http://forum.phillw.net/viewtopic.php?f=4&t=4
Regards,
Phill.