Installing LAMP stack in Ubuntu

Installing LAMP stack in Ubuntu

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 the 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 the 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 the 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 the following URL to see the 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 the 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 the User interface of MySQL by executing the following command in your terminal.

sudo apt-get install phpmyadmin

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

localhost/phpmyadmin

Now we have completed our installation of the LAMP stack.

Installing complete LAMP stack with one command:

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 coordinated "task" onto your system. For installing tasksel execute the following command in your terminal.

sudo apt-get install phpmyadmin

The second time for LAMP stack in one go execute the following command.

sudo tasksel install lamp-server

Now we get our completed LAMP stack in two steps.

Add new comment

The content of this field is kept private and will not be shown publicly.

Hostinger