Install LAMP Stack (Apache, MariaDB, php, phpMyAdmin) on Ubuntu 14.04, 14.10, 15.04, 15.10 & 16.04

3a) Set MySQL root password

By default Debian based systems will ask for MariaDB root password when you are proceeding installation.

Run mysql_secure_installation command to adjust other settings to make your database more secure such as removing anonymous users, Disallow root login remotely, Remove test database and access & Reload privilege tables.

On RPM based systems wont ask you to set the password while installation but DEB system will ask, that’s why we are giving N for root password section.

[MariaDB Secure installation]
$ sudo mysql_secure_installation

Enter current password for root (enter for none): Enter Your Current Password
OK, successfully used password, moving on...

Set root password? [Y/n] n
 ... skipping.

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] y
 ... Success!

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

4) Install PHP

Use the below command to install PHP. PHP initially called
Personal Home Page, now it is called asHypertext Preprocessor. PHP is a open-source software which is designed for web development purpose. It is used for server-side scripting language as well as general-purpose programming language.

[Install php5 old systems] 
$ sudo apt-get install php5 php5-mysql php5-cli php5-curl php5-gd php5-mcrypt

[Install php7]
$ sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-mbstring php7.0-common php7.0-gd php7.0-mcrypt php-gettext php7.0-curl php7.0-cli

Create test php file to check whether php is working with apache or not.

[Creating php info file]
$ sudo nano /var/www/html/phpinfo.php
<?php phpinfo(); ?>

[Restart apache service]
$ sudo systemctl restart apache2

Open your web browser and navigate to http://localhost/index.php or http://your-server-ip-address/index.php or http://127.0.0.1/index.php
install-lamp-on-ubuntu-16-04-php

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...