How to Install LAMP with PHP 7 and MariaDB 10 on Ubuntu 16.10

In this article, we will go through the various steps to install the constituent packages in LAMP stack with PHP 7 and MariaDB 10 on Ubuntu 16.10 Server and Desktop editions.

As you may already know, LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack is the assortment of leading open source web development software packages.

This web platform is made up of a web server, database management system and a server-side scripting language, and is acceptable for building dynamic websites and a wide range of web applications. It can be used in a testing or production environment to support small-scale to very large web-based projects.

One of the common uses of LAMP stack is for running content management systems (CMSs) such as WordPress, Joomla or Drupal and many others.

Requirements

Step 1: Install Apache on Ubuntu 16.10

1. The first step is to start by installing Apache web server from the default Ubuntu official repositories by typing the following commands on terminal:

$ sudo apt install apache2
OR
$ sudo apt-get install apache2

Install Apache on Ubuntu 16.10

2. After Apache web server successfully installed, confirm if the daemon is running and on what ports it binds (by default apache listens on port 80) by running the commands below:

$ sudo systemctl status apache2.service
$ sudo netstat -tlpn

Check Apache Status and Port

3. You can also confirm apache web server via a web browser by typing server IP address using HTTP protocol. A default apache web page should be appeared on the web browser similar to the below screenshot:

http://your_server_IP_address

Verify Apache Web Server

4. If you want to use HTTPS support to secure your web pages, you can enable Apache SSL module and confirm port by issuing the following commands:

5. Now confirm Apache SSL support using HTTPS Secure Protocol by typing the below address in web browser:

https://your_server_IP_address

You will get the following error page, its because that apache is configured to run with a Self-Signed Certificate. Just accept and proceed further to bypass the certificate error and the web page should be displayed securely.

Apache Self-Signed Certificate Error

Apache HTTPS Support Enabled

6. Next enable apache web server to start the service at boot time using following command.

$ sudo systemctl enable apache2

Step 2: Install PHP 7 on Ubuntu 16.10

7. To install most recent version of PHP 7, which is developed to run with speed enhancements on Linux machine, first do a search for any existing PHP modules by running the below commands:

$ sudo apt search php7.0

APT Search PHP 7 Modules

8. Once you came to know that proper PHP 7 modules are needed to setup, use apt command to install the proper modules so that PHP can able to run scripts in conjunction with apache web server.

9. After PHP7 and its required modules are installed and configured on your server, run php -v command in order see the current release version of PHP.

$ php -v

Check Installed PHP Version

10. To further tests PHP7 and its modules configuration, create a info.php file in apache /var/www/html/ webroot directory.

$ sudo nano /var/www/html/info.php

add the below lines of code to info.php file.

<?php
phpinfo();
?>

Restart apache service to apply changes.

$ sudo systemctl restart apache2

Open your web browser and type the following URL to check the PHP configuration.

https://your_server_IP_address/info.php

Check PHP Configuration

11. If you wanted to install additional PHP modules, use apt command and press [TAB] key after php7.0 string and the bash autocomplete feature will automatically show you all available PHP 7 modules.

$ sudo apt install php7.0[TAB]

List All Available PHP 7 Modules

Step 3: Install MariaDB 10 in Ubuntu 16.10

12. Now it’s time to install latest version of MariaDB with the needed PHP modules to access the database from Apache-PHP interface.

$ sudo apt install php7.0-mysql mariadb-server mariadb-client

Install MariaDB in Ubuntu 16.10

13. Once MariaDB has been installed, you need to secure its installation using the security script, which will set a root password, revoke anonymous access, disable root login remotely and remove the test database.

$ sudo mysql_secure_installation

Secure MariaDB Installation in Ubuntu 16.10

14. In order to give MariaDB database access to system normal users without using sudo privileges, login to MySQL prompt using root and run the below commands:

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

Try to manually enable phpMyAdmin by copying its apache configuration file located in /etc/phpmyadmin/ path to Apache webserver available configurations directory, located in /etc/apache2/conf-available/: