How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu 16.04, Ubuntu 18.04 and Ubuntu 20.04 LTS

How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu
How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu OS

Hello friends, In this tutorial will teach you how to install LAMP on the Ubuntu Operating system. The LAMP stands for  Linux, Apache, MySQL, and PHP.  It is the most popular stack for creating and deploying dynamic web applications and the basis for popular CMS systems like Joomla, WordPress, or Drupal.

This will be the step-by-step brief tutorial to install the LAMP stack. we will download and install PhpMyAdmin to make MySQL administration easier to access. And also fix some known errors that come while installation.

Lets start our LAMP installation Steps:-

Prerequisite:

Need sudo user privileges.

Step1. Update Ubuntu repository using the following command.


sudo apt update


Step2. Now install Apache2 webserver.


sudo apt install apache2


Step3. Now check the Apache server status {start, stop and status}


sudo service apache2 status

or


sudo /etc/init.d/apache2 status


Step4. Install Mysql Databases Server.

By default it will install mysql 5.7. During installation, you’ll be asked to set-up the MySQL “root” user password. Enter the password and click Ok. Re-enter the password. 


sudo apt install mysql-server


Step5.  Login Mysql database with a password.


mysql -u root -p

 How To Install LAMP) on Ubuntu 20.04

Step6. Install php 7.2

To install php7.2 we have to add the PPA repository as a source for new software. PHP 7.2 is the stable version and can be used for production.
If you wish to install another php version then click here


sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.2

To Check php version type php –v or php –version
To test PHP with Apache server, first, create a info.php file in the Web root directory that is /var/www/html/


cd /var/www/html/
sudo vim info.php


Paste the following PHP code into the file.


<?php
        phpinfo();
 ?>

Press “i” to insert into the file and  for save and exit press Esc key + “:” + wq!

Now in the browser address bar, enter server-ip-address/info.php. Replace server-ip-address with your actual IP. If you follow this tutorial on your local computer, then type 127.0.0.1/info.php or localhost/info.php.

Step7. Download PhpMyadmin

Go to a web browser and type https://www.phpmyadmin.net/downloads/ to download PHPMyAdmin.
Unzip phpMyAdmin-5.0.2-all-languages.zip folder and rename to phpmyadmin

How To Install (LAMP) on Ubuntu 20.04


unzip phpMyAdmin-5.0.2-all-languages.zip
mv phpMyAdmin-5.0.2-all-languages.zip phpmyadmin

Now go inside phpmyadmin folder and rename confi.sample.inc.php to config.inc.php

Move phpmyadmin folder to /var/www/html/ folder and restart the apache2 service.

Now go to a web browser and type http://localhost/phpmyadmin
Enter your MySQL username and password.

If you get some error like The configuration file now needs a secret passphrase (blowfish_secret).  after login into phpmyadmin then we have a solution. Click here to get fixed.

Step8. Fix mysqli error

How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu 16.04
How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu 16.04

 
sudo apt install php7.2-mysql


Now go to browser and  check it. 

Conclusion:

Congrat’s you have successfully installed (LAMP) Apache, Mysql, PhpMyAdmin, and PHP7.2 on Ubuntu 16.04, Ubuntu 18.04 and Ubuntu 20.04 LTS. If this post was really helpful then please like the post and let me know if you are facing any problem in installing in the comment box. Happy learning.

Also Read:- The configuration file now needs a secret passphrase (blowfish_secret).

Also Read:- How to Install MySQL 8.0 on Ubuntu 20.04 LTS.

Also Read:- Install and setup Laravel 7 on Ubuntu 18.04 and 20.04 LTS

Leave a Reply

Your email address will not be published.