Installing LAMP stack in Ubuntu

Installing LAMP stack in Ubuntu

In today’s world websites and web applications is one of the most common things we interact in our lives. LAMP stack is one of the technologies combinations the run behind the scenes. LAMP stack plays major roll in the development of great websites or web applications.  LAMP stack is a bundle of open source software used to create one of the powerful web servers. The acronym stands for Linux, Apache, MySQL, and PHP. Diagram for LAMP stack:

There are two ways to install LAMP stack in Ubuntu :

Installing each package individually :

For installing each package individually follow the following steps:

First of all install Apache web-server, generally recognized as the world's most popular Web server by executing this command to your terminal. For our example, we are using latest Apache2.

sudo apt-get install apache2

Time to test open your browser and hit the following URL you will see a message saying "It works!”

localhost/

Second, install PHP open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. For our example, we are using latest version of PHP i.e. PHP5

sudo apt-get install php5 libapache2-mod-php5

For connecting Apache2 and PHP5 we also install libraries in above command. After this restart your Apache2 services by the following command.

sudo /etc/init.d/apache2 restart

Time to test create a file with the info.php name in your /var/www/ directory and write the following code in it.

Creating file:

sudo gedit /var/www/info.php
<?php phpinfo(); ?>

Save the file. Now open your browser and hit following URL to see given page.

localhost/info.php

Third, it’s time for our MySQL world's second most widely used open-source relational database management system. Execute the following command to your terminal.

sudo apt-get install mysql-server

For connecting MySQL and PHP5 we need to install libraries by executing following command.

sudo apt-get install php5-mysql

Again we have to restart our Apache2 web-server with the following command.

sudo /etc/init.d/apache2 restart

You can also install User interface of MySQL by executing following command in your terminal.

sudo apt-get install phpmyadmin

Time to test hit following URL to your browser and see the given page.

localhost/phpmyadmin

Now we have completed our installation of LAMP stack.

Installing complete package in one go:

For installing the complete package in one go follow the following steps:

First, we need to install an ubuntu’s tasksel tool which is used for installing multiple related packages as a co-ordinated "task" onto your system. For installing tasksel execute the following command in your terminal.

sudo apt-get install phpmyadmin

Second time for LAMP stack in one go execute following command.

sudo tasksel install lamp-server

Now we get our completed LAMP stack in two steps.

Tags