$10 off Wordpress Professional Hosting

The deal ends in

How to upgrade to PHP 7 on Ubuntu with Apache and mod php.

<h2>Prerequisites</h2>
It’s always best to upgrade your php version to the latest stable version but keep in mind, your website must be able to handle the upgrade. This tutorial assumes that you’re running Ubuntu Trusty and Mod php. You must have the ability to run these commands as root or as a sudo user.
<div class=”alert alert-warning alert-dismissible fade in”>If your website is on a shared host, this tutorial does not apply. You may need to submit a support ticket for your hosting provider to upgrade your php version.</div>
Without further adieu, let’s start.

First, log into your web server using ssh.
<h2>Add the personal package archive(PPA)</h2>
PPA’s are a way for private developers to create and distribute Linux packages. This particular package is maintained by Ondřej Surý.

[code]sudo add-apt-repository ppa:ondrej/php [/code]

After going through the process, the system will prompt you. At this stage, you can press Enter.

Once the package is setup, you will then need to clear the package cache of your server.

[code]sudo apt-get update[/code]

<h2>Installing PHP 7.1</h2>
At this stage, we’re going to install PHP 7.1. without removing PHP 5.x. As a developer, I’ve come to realize that php 5 is still needed since many platforms like Magento 1.x does not support php 7. Leaving php 5 allows us to switch between the two, just in case.

[code]sudo apt-get install php7.1[/code]

<div class=”alert alert-warning alert-dismissible fade in”>You’ll notice a very interesting issue. When you run the command

[code]php -v[/code]

, the output will say you’re running php 7.1. Yet when you verify PHP using a php info script in your web browser, it’s reporting your previous php version. What gives? You’ve installed PHP 7, but you did not enable it so Apache assumes you’re still running mod PHP 5.</div>
Let’s Continue!
<h2>Enabling PHP 7 Module</h2>
Let’s disable the PHP 5 module and enable the PHP 7 module.

[code]sudo a2enmod php5 [/code]

[code]sudo a2enmod php7.1[/code]

<h2>Additional modules to install</h2>
Now that you’ve upgraded, you need to install one additional module which is the PHP Mysql module. This module will help with the communication between PHP and the Mysql database. This assumes you’re using MySQL of course.

[code]sud0 apt-get install php7.1-mysql[/code]

If you’re using PostgreSQL

[code]sud0 apt-get install php7.1-pgsql[/code]

<h2>Restarting Apache</h2>
After every change made to the apache config or a new module is installed, you must always restart Apache. The only time you will not need to restart Apache is when .htaccess is updated.

[code]sudo service apache2 restart[/code]

Related articles

Easiest website builders for 2022 – top 2

Are you looking for the easiest website builders recommended for beginners? Look no further we have done the market research to help you find the easiest website builders for your website. In America, we are almost halfway through 2022. It is absolutely

Read More »
how to do seo for your website step-by-step
Small Business
Hosterfi

How to do seo for your website step-by-step

Handling your own SEO is a dire job. Until now, here’s how to do SEO for your website step-by-step with the right tools and keyword research. It is, in fact, a job on its own but there are easy tools out there

Read More »
The steps of using MarketGoo DIY SEO Software
Small Business
Hosterfi

DIY SEO Software for Small Businesses

The problem Why do you need a DIY SEO software for your small business? As a small business owner, there are a lot of expenses that come along with running your business. Since COVID 19, some businesses are on the brink of

Read More »

Sign up for our newsletter

Get the latest in discounts, news, and blog updates

Logo representing a veteran owned business
Talk.to partner logo