Downgrade PHP 7.2 to PHP 7.1 with Apache2 HTTP Server on Ubuntu 16.04 / 17.10 / 18.04

Some applications do not yet support PHP 7.2… if you’re currently running applications that do not fully support PHP 7.2, you should probably downgrade to a supported versions of PHP…

For instance, Ubuntu 18.04 doesn’t include PHP 7.1 packages by default… so if you upgrade and attempt to run an application that doesn’t fully support PHP 7.2, you may run into issues..

This brief tutorial shows students and new users how to run Ubuntu 18.4 but still install PHP 7.1 to support your apps… This post should be quick and easy.. The good thing about this is you can install PHP 7.1 along with PHP 7.2 and have multiple applications with different PHP needs..

Some apps can be configured to support PHP 7.2 while others support PHP 7.1

For this post, we’re going to be supporting PHP 7.1 only on Ubuntu

If you can’t get PHP 7.1 packages on Ubuntu by default, you’ll want to add this third party repository to your system… the repository contains multiple versions of PHP packages…

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

After adding the repository, you can now go and install PHP 7.1 and related modules…

sudo apt install php7.1
sudo apt install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip

The main configuration file for PHP 7.1 with Apache2 support can be found at

sudo nano /etc/php/7.1/apache2/php.ini

In the file above is where you configure PHP related settings with Apache2 support… Some cool settings are:

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 64M
max_execution_time = 30
display_errors = Off
max_input_vars = 1500
date.timezone = America/Chicago

After making those changes save the file and exit.

Now, if you don’t want to run PHP 7.2, run the commands below to disable it for Apache2…

sudo a2dismod php7.2

Then run the commands below to enable PHP 7.1 for Apache2 to use…

sudo a2enmod php7.1

Restart Apache2 for the changes to apply by running the commands below…

sudo systemctl restart apache2.service

That’ it! Now PHP 7.1 should be the default PHP processor.

You may also like the post below:

Install X2CRM on Ubuntu 16.04 / 17.10 / 18.04 with Apache2, MariaDB and PHP 7.2 Support

2 Replies to “Downgrade PHP 7.2 to PHP 7.1 with Apache2 HTTP Server on Ubuntu 16.04 / 17.10 / 18.04

  1. If at the end I execute sudo apt-get remove php7.2 it does not break work of php 7.1?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: