Install Apache2 with PHP 7 support in Ubuntu 16.04 server

Sponsored Link
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

PHP is a popular general-purpose scripting language that is especially suited to web development.

Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.

This tutorial will explain how to install Apache2 with PHP 7 support in Ubuntu 16.04 server

Install Apache2 server

This is very simple to do from the server command line run the following command

sudo apt-get -y install apache2

After completing the installation you can test using the following URL from web browser

http://serverip

You should see similar to the following screen

1

Note:- document root of the apache2 default vhost is /var/www/html and configuration file location is /etc/apache2/apache2.conf

Install php7 in ubuntu 16.04 server

run the following commands in ubuntu 16.04 server command prompt this will install apache2 supported module for php7

sudo apt-get -y install php7.0 libapache2-mod-php7.0

After the installation you need to Restart the apache2 server using the following command

sudo systemctl restart apache2

Test PHP installation

We need to create test.php file under /var/www/html

sudo vi /var/www/html/test.php

add the following code and save the file

<?php
phpinfo();
? >

Change the owner of the file test.php to the www-data user and group

sudo chown www-data:www-data /var/www/html/test.php

Now go to http://serverip/test.php and you should see similar to the following screen here you can see php7 is enabled for apache2.

2

3

Sponsored Link

You may also like...

2 Responses

  1. jeremy seyssaud says:

    Hi,
    when i go to http://serverip/test.php i have only

    on the screen …

  2. mrberner says:

    Works fine, good tut 🙂

Leave a Reply

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