Installing Lamp on Ubuntu Linux 12.04 is fairly easy , which takes few commands that you have enter in your terminal and then you are all set with your brand new Lamp Installation on Ubuntu Linux 12.04
Now Linux is one such place where you can install your own LAMP server using just few commands and some tweaks.
1. Installing LAMP on Ubuntu 12.04Go to terminal and type the command
sudo apt-get install lamp-server^
This would take you to the download packages confirmation and then you will be prompted with the screen to choose your desired password for MYSQL with one more screen coming up to confirm your password. The package manager will install the remaining packages and that is it. You are finished with your Lamp installation.
So in brief:
1(a) Write the above command in terminal and hit enter.
1(b) Choose and reconfirm the desired root password for Mysql.
1(c) That is it. Your Lamp install is finished.
2. Testing if Apache is working
Go to http://localhost/ to see if your Apache configuration is working. If you see a page that is titled as
It Works!, your Apache is working and configured correctly.
3. Testing to confirm that PHP is working.
Now there are two ways to do that.
first is that either you go to your var/www directory and create a file and name it as testforphp.php, using a text editor and write only this content in that file ( the php file that you have made inside /var/www) to test your PHP)
"<?php phpinfo(); ?>"
(Without the inverted commas)
just copy and paste this command in the terminal
echo "<?php phpinfo(); ?>" | sudo tee /var/www/testforphp.php
Now go to http://localhost/testforphp.php
If you see a description of PHP, it means your PHP works with Apache.
4. Installing phpMyAdmin
You will also have to install phpMyAdmin on your LAMP server . To do this, just type in the following command in your terminal
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
After you hit enter, you will prompted with a screen to choose form apache2 and lighttpd. You have to choose apche 2 in case you are wondering whether to choose apache2 or lighttpd. Choose apache2 and hit enter.
You will be presented with a screen for configuring phpMyAdmin. Choose yes when you are prompted to configure database for phpmyadmin with dbconfig-common.
Enter the mysql root password that you ahve entered before in configuring mysql and you are good to go.
Go to http://localhost/phpmyadmin/ to check that your phpMyAdmin is working. Login with the username root and the password that you choose while configuring Mysql.
5.Making the /var/www directory writable.
You will have to make the /var/www directory writable before you can start with any web development on your LAMP server install.
To do that, just copy and paste the following commands in your terminal and your are good to go.
sudo adduser username www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rw /var/www
Replace username with your username on Ubuntu and that is it. You are now ready with your Lampmap server install on Ubuntu Linux 12.04 with all the proper permissions for your /var/www directory.