How to install LAMP on ubuntu 12

Here we will see how to install LAMP(Linux Apache MySQL and PHP) in Ubuntu 12 using commands. LAMP is used to run PHP scripts and use data which is stored in database(MySql) with those scripts. To do this you will need command prompt that is your terminal and root access to your system. To open terminal in Ubuntu 12 open Unity sidebar and click on first icon on it or click windows key, and search for terminal. Type "su" and then enter your password. Then follow these commands.


To install LAMP on Ubuntu, we will first start wih Apache server.
Installing Apache Server:
To install apache2 in ubuntu write below command
sudo apt-get install apache2
This will ask you two comnfirmations, write "y" and click "Enter".
Now you have installed Apache server successfully.
To check whether you are going in proper direction, open your browser and type "http://localhost/",
It will show "It works!" in big bold letters.
Next step is to install PHP:
To install PHP copy(ctrl+c) and paste into terminal(ctrl+shift+v)
sudo apt-get install php5 libapache2-mod-php5

This will too ask you two confirmation for which write "y" and click "Enter".
Now to check whether it is installed properly you have to create a simple PHP file and put it under "/var/www/" folder,
To create a file without using terminal you first have to give write permissions to your "www" folder. 
For that use below command,
chmod -R 777 /var/www
Now create any .php file and write below code in it
  print phpinfo();
I changd the default index.html file to index.php file and wrote this code in it.
Now run this file from your browser by entering http://localhost/ and filename. Ta da you have now successfully installed PHP in your system.
Installing MySQL:
 To install mysql server copy(ctrl+c) and paste into terminal(ctrl+shift+v)

sudo apt-get install mysql-server

 Now this time it will ask you a confirmation and if you press "y+Enter" it will start installing mysql server on your system.


It will then ask password for the root user.(Be careful while entering password at this stage as you will need this later on.)

And now you are done installing Mysql server, if you want you can check it by opening a new tab in your terminal (Ctrl+Shift+t).

Enter "mysql -u root -p" in your terminal and press enter, you will be asked for the password. Enter password which you set during installation.

You will see "mysql>" in your terminal and you are now able to use mysql.



thank u i was searching for same.

Add new comment