Valitron: Easy Validation
April 22, 2017
Find how many Friday in a month in php ?
May 10, 2017
Show all

How To Install LAMP Stack On Ubuntu 16.04

LAMP is the combination of operating system and open-source software stack. The elaboration of LAMP is L-Linux, A-Apache HTTP Server, M-MySQL or MriaDB database and P-PHP/Perl/Python. The main advantages of LAMP stack is that it’s a package of powerful application for web development and all applications are open source and freely available to download but have to pay for professional tools. It is also called FOSS(Free or Open Source Software) . This article describes how to install LAMP stack on ubuntu 16.04.

Step: 1 Update the System

We need to install 4 Packages to install LAMP Stack. Such as Apache Webserver, My SQL Database Server, PHP and PHP MyAdmin.

Before Install above packages Let’s install/update newer version of packages and their dependencies of Ubuntu 16.04. So update the packages by below command.

As shown on above snapshot all packages are now up to date, Now use below command to Install Apache Web Server.

Step: 2 Install Apache

Apache is an open-source multi-platform web server. It provides full range of web server including CGI, SSL and virtual domains.

To install Apache, just enter the command:

Now it’s asking to Enter “Y” to proceed for further installation, So press “Y

As we can see above the apache2 Package installed successfully, We can verify if apache2 package is installed or not by below command.

Now open the Web-Browser and enter “localhost” to check apache2 default page is showing or not.

Step: 2 Install PHP Package

As we know that LAMP Stack is a open source application which is used to host PHP based websites, So for that let’s go ahead and install php by below command.

Now it’s asking to Enter “Y” to proceed for further installation, So press “Y

As we can see above the php package installation process has been completed, We can verify if php package is installed or not by below command.

As we can see above php is installed, now restart the apache2 service to take effect by below command.

Now let’s go ahead and test if php is working properly or not, for that create a file under Document Root of apache i.e. “/var/www/html” and then enter “<?php phpinfo(); ?>” to check php information.

Follow the below steps to do the same :-

Enter the below code in file to check if php is working fine and then save.

<?php phpinfo(); ?>  # to check the PHP Information

Restart the apache2 service then open the web browser and then enter “http://localhost/file.php”.

It shows a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License.

Step: 3 Install Mysql Server Package

Now it’s time to install mysql-server, follow the below command to install the same.

It’s asking to Enter “Y” to proceed for further installation, So press “Y

Then its asking to set the password for mysql-server login for the user “root“.

Confirm the password by Re-Entering the same password.

mysql-server installation process has been completed, we can verify if mysql-server package is installed or not by below command.

Let’s check if mysql-server is working properly by creating a database, Please follow the below steps to do the same.

After above command it will ask to enter password for mysql-server, now here enter the password which we have set during mysql-server installation process.

As we can see above mysql-server logged in successfully and the prompt changed to “mysql>“.

Now enter the below command to create a database on “mysql>“ prompt.

Now to verify if database created or not enter the below command.

As we can see on prompt the database “usersdb” created successfully.

Step: 4 Install PhpMyAdmin Package

Now let’s go ahead and install our last package for LAMP Stack i.e phpmyadmin by using below command.

It’s asking to Enter “Y” to proceed for further installation, So press “Y

Select apache2 and then press OK to proceed the installation process further as shown on the snapshot above.

Then press “Yes” to Configure database for phpmyadmin with dbconfig-common.

Now set password for phpmyadmin login purpose for user “root”.

Confirm the password by Re-Entering the same password.

As we can see above phpmyadmin installed successfully, now use below command to verify phpmyadmin package installed or not.

We can open phpmyadmin webaccess by using URL “http://localhost/phpmyadmin” but before that we have to configure “php.ini” and “apache.conf” file, So Follow the below steps to do the same.

edit the “php.ini” and search for extension=msql.so

Note:- “php.ini” file location may be different as per version

Now search for extension=msql.so and Uncomment the line by removing the Semi-Colon as highlighted above on the snapshot.

After uncomment extension=msql.so it would look like this as shown above on the snapshot, then save php.ini file.

Now edit the “apache2.conf” file by using below command.

Then go to the end of the configuration file and add the below line.

Include /etc/phpmyadmin/apache.conf

Please refer the above snapshot to do the changes in “apache2.conf” file then save the file.

Now restart the apache2 service.

Now open PhpMyAdmin web access by entering the below URL on web browser.

http://localhost/phpmyadmin

OR you can access on other system which should be in same network by entring below URL.

http://<IP Address of the LAMP Server>/phpmyadmin

As we can see nice phpmyadmin web access on snapshot above, now login it by using username as “root” and use the password we have set during phpmyadmin package installation.

Now as we can see below on the snapshot the phpmyadmin web access successfully logged in and showing the database we have created in mysql-server named “usersdb” highlighted below.

This is how we can install LAMP Stack on Ubuntu 16.04.

 

Leave a Reply

Your email address will not be published. Required fields are marked *