Installing LAMP on ubuntu

LAMP – Linux Apache Mysql Php

If you are thinking of web development and you are a free and open source software lover, then LAMP is the ideal tool for you in developing high-ended dynamic web applications…

Here, i’ll show you how to install LAMP on a Linux system that is running the Ubuntu flavor OS…..

So let’s get started…….

  • Install Apache 

We install Apache first – which is the web server.

Open the terminal by: ctrl+alt+t and copy, paste the following command in your terminal:

sudo apt-get install apache2

Enter the password to grant administrative privileges and press enter….

In order to test whether apache is running or not open your web browser and type:


You will see a default folder, open it and you’ll see the message: It Works! 

You have installed apache on your system.. Great!!

Sometimes it may require to restart your apache server.. In order to restart, issue the following command:

sudo /etc/init.d/apache2 restart

  • Install PHP
We install PHP now, the server-sided language for making dynamic web pages….
Open the terminal (ctrl+alt+t) and issue the following command:

sudo apt-get install php5 libapache2-mod-php5

Then, restart your apache server by issuing:

sudo /etc/init.d/apache2 restart

Now we test whether PHP is working or not…

open the text editor and create a file called hello.php using the following command:

sudo gedit /var/www/hello.php

This will create and open the hello.php file in your text editor; copy and paste the following code:

<?php echo “Welcome to the World of PHP!!”; ?>

Save and close the file…. Open your web browser and hit:


And you will see the text Welcome to the World of PHP!!

Great!! You have now successfully installed apache and php on ubuntu…

  • Install MySQL
Open the terminal and issue the following command:
sudo apt-get install mysql-server’
After this we need to set the password for our MySQL database.. The username by default is root…
On your terminal issue the following:

mysql -u root

Now we’ll assign a password.. Copy and Paste the following code:

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘mypassword’);

mypassword is your desired password… The username and password is the key to access your MySQL db…

Now the interesting part…

We’ll install a program called phpmyadmin.. This is a GUI twhich helps you in creating and working with databases which is quick and highly user-friendly…..

Issue this command in your terminal:

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

After this, next are required to enable our php to work with our MySQL db… To do we have to edit the php.ini file in the  /etc/php5/apache2 directory.. Issue the following command in your terminal:

gksudo gedit /etc/php5/apache2/php.ini

Once open search for the line:


This is a comment, we need to uncomment this by removing of the semi-colon that looks like:

Now restart the apache web server:

sudo /etc/init.d/apache2 restart

That’s it folks.. Your installation of LAMP is successful on your system…. So get started with your open development….. 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s