Install Apache2 with PHP 7 support in Ubuntu 16.04 server
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
You should see similar to the following screen
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
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.