LAMP stack is an acronym which stands for the Linux operating system alongside with Apache web server, MySQL/MariaDB database and dynamic PHP programming language which facilitates the deployment of dynamic web applications.

Install Apache, PHP-7 and MariaDB 10 on Ubuntu-16.04

Install Apache, PHP-7 and MariaDB 10 on Ubuntu-16.04

In this guide we will discuss how to install LAMP stack on Ubuntu 16.04 Server with new released of PHP 7 version and MariaDB 10 version.

Requirements

  1. Ubuntu 16.04 Server Installation Guide

Step 1: Install Apache on Ubuntu 16.04

1. On the first step will start by installing one of the most popular web servers today in internet, Apache. Install Apache binary package in Ubuntu from their official repositories by typing the following commands on console:

$ sudo apt install apache2
OR
$ sudo apt-get install apache2
Install Apache on Ubuntu 16.04

Install Apache on Ubuntu 16.04

2. Once Apache web server has been installed on your system, verify if the daemon is started and on what ports it binds (by default it listens on port 80) by issuing the below commands:

$ sudo systemctl status apache2.service $ sudo netstat –tlpn
Start Apache Service

Start Apache Service

Verify Apache Port

Verify Apache Port


3. You can also verify if apache service is running by typing your server IP address in a web browser using HTTP protocol. A default web page should be displayed on the browser similar to the following screenshot:

http://your_server_IP_address
Apache Default Page

Apache Default Page

4. Because accessing web pages using HTTP protocol is highly insecure, further will start enabling Apache SSL module by issuing the following commands:

$ sudo a2enmod ssl $ sudo a2ensite default-ssl.conf $ sudo systemctl restart apache2.service
Enable Apache SSL Module

Enable Apache SSL Module

Confirm if the server is properly binding on default HTTPS port 443 by running netstat command again.

# sudo netstat -tlpn

5. Also, verify the default informational apache web page using HTTP Secure Protocol by typing the below address in your browser:

https://your_server_IP_address

Due to the fact that apache is configured to run with a Self-Signed Certificate, an error should be displayed on your browser. Just accept the certificate to bypass the error and the page should be securely displayed.

Apache SSL Certificate Confirmation

Apache SSL Certificate Confirmation

Apache Running on HTTPS

Apache Running on HTTPS

Step 2: Install PHP 7 on Ubuntu 16.04

6. PHP is an Open Source dynamic programming language which can connect and interact with databases to process you code embedded in HTML code in order to create dynamic web pages.

To install the latest version of PHP 7, which is designed to run with speed improvements on your machine, first start by performing a search of existing PHP modules by issuing the below commands:

$ sudo apt search php7.0
Search PHP 7 Modules

Search PHP 7 Modules

7. Next, once you found the proper PHP 7 modules required for your setup, use apt command to install the proper components so that PHP can execute code in conjunction with apache web server.

$ sudo apt install php7.0 libapache2-mod-php7.0
Install PHP 7 in Ubuntu 16.04

Install PHP 7 in Ubuntu 16.04

8. Once the PHP7 packages are installed and configured on your server, issue php -v command in order get the current release version.

$ php -v
Check PHP Version

Check PHP Version

9. To further tests PHP7 configuration on your machine, create a info.php file in apache webroot directory, located in /var/www/html/ 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

And navigate to your server IP address at the below URL to check the final result.

https://your_server_IP_address/info.php 
Check PHP 7 Information

Check PHP 7 Information

10. If you need to install extra PHP modules on your server, just press [TAB] key after php7.0 string when using apt command and the bash autocomplete option will automatically list all available modules for you.

Choose the proper module and install it as usual. We strongly advise you to install the following Php additional modules:

$ php7.0-mbstring php7.0-mcrypt php7.0-xmlrpc
$ sudo apt install php7.0[TAB]
Install Additional PHP 7 Modules

Install Additional PHP 7 Modules

Facebook Comments
Spread the love

Posted by News Monkey