How To Install Ubuntu 16.04 LAMP server with Apache 2.4, PHP 7 and PHP 5.6 (Active PHP 5.6 instead of PHP 7),MYSQL

Initiation
LAMP (Linux + Apache + MySQL + PHP/Perl/Python) is a bundle of open source software.Advantage of open source-LAMP is the considerable flexibility for different kind of database, web server, and server side scripting languages.We can use PostgreSQL and SQLite instead of MYSQL. Ruby,Perl, and Python are also frequently used instead of PHP. We can use Nginx, Cherokee and Lighttpd instead Apache. In this session, we’ll get a LAMP stack installed on an Ubuntu 16.04 LTS.

Install Linux, Apache, MySQL, PHP LAMP Stack On Ubuntu 16.04

 

Step 1: Update apt-get package lists and Install Apache

Note: Above command is using “Sudo” keyword.These process get executed with root privileges. It will ask you for your regular user’s password to verify your intentions.

Validate and start apache

Validate apache installation:

Open your web browser and navigate to http://localhost/ or http://server-ip-address/.

 

install-lamp

 

Step 2: Install PHP and add PPA

Ubuntu 16.04 comes with php 7.0, and some php applications might still fail with php 7.0 .Therefore, in some cases, it might be sensible to have both php 7.0 and php 5.x, so that you can choose which version to use for your needs at any time.

To add the PPA to your setup:

Install PHP

Validate PHP:
Create a test-info PHP file called info.php in /var/www/html/. You can use nano command to create and update the file like below:

Insert the following code and save and exit:

Ctrl+O and Enter (Save)
Ctrl+X                  (Exit)

 

install-php

 

You can switch from  php 7.0 to php 5.6 and vice versa.  you need to do following things:

Switch php5.6 to php 7.0:

Switch php7.0 to php5.6:

Validate current php version :

 

install-php

 

Step 3: Install MySQL

Install the mysql-server package and choose a secure password when prompted:

During the install, it will prompt you to enter a MySQL root password. Set any password that you would like. It should be a strong password.

 

install-php

 

After you enter your MySQL root password, you will need to re-enter it.

install-php

 

Validate the MySQL is running with the following command:

Step 4:  Install PhpMyAdmin  (Optional)

phpMyAdmin is a tool by which you can manage your MySQL databases. phpMyAdmin is released under GNU General Public License, version 2.

So can install it with below command:

Select the apache2 as Web server that should be automatically configured to run phpMyAdmin.
install-php

 

You can select “Yes”  as default  (dbconfig-common) configuration for phpmyadmin.

install-php

 

Enter password of the database administrative user.

install-php

 

Enter MySQL application password for phpmyadmin:

install-php

 

Re-enter password:

install-php

 

phpMyAdmin installation is done.

Update the apache configuration in case phpMyAdmin is not working, please do the following steps.

Open terminal, and type:

Insert the following line at the end then save and exit:

Ctrl+O and Enter (Save)
Ctrl+X                  (Exit)

Validate the phpMyAdmin :

Open your web browser and navigate to http://localhost/phpmyadmin or http://server-ip-address/phpmyadmin

 

Enter your MySQL username and password which you have given in previous steps.Then You will be redirected to PhpMyAdmin main web interface.

 

 

That’s it. Your LAMP with Apache 2.4, PHP 7 and PHP 5.6 stack is ready to use.

Leave a Reply

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

Please complete the CAPTCHA *