Hyper Expert /Blog
About
Archives

HOW-TO: Install PHP7 on Ubuntu 16.04 LTS

Installing PHP7 on Ubuntu is very simple. Once you are logged on to your Ubuntu instance, launch Terminal if in GUI or just issue the commands below (server – without GUI):

Install PHP without Apache2

For only when you want to install PHP Command Line Interface to run PHP scripts without a web server

sudo apt-get install php-cli

If you have Apache2 Web Server installed

– follow this guide to install Apache2 Web Server if not already installed

sudo apt-get install php libapache2-mod-php

Verify the packages that will be installed, then type y for yes and press Enter

Thats it! To verify that PHP is working, create a new phpinfo file in your Apache2 directory (default – /var/www/html/) and name it info.php

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

This will create a new blank file in /var/www/html/ called info.php

Write the code below in the file then save and close

<?php phpinfo(); ?>

In your browser, navigate to your phpinfo file, if all worked, you should see your PHP information like in the screenshot below

///////////

Hi, my name is Ali. I am a Systems Engineer. I live in the beautiful Evergreen state. I have a Bachelor degree of science in Information Technology with a handful of accompanying I.T. certificates. I also have a degree in Computer Networking. I am an Apple Certified Technician, Microsoft MCITP and a Linux expert.

Would you like to share your thoughts?