This guide will show you how to install different version of PHP on Ubuntu, and Debian. For the sake of this guide, we will demonstrate PHP 7.1 installation steps on an Ubuntu 16.04. However, these instructions can also be applied if you are running Ubuntu 17, 18, 19, or 20.04.
Add PHP Repository
If you are on Ubuntu 16, the only version of PHP available in its default repository is 7.0 and therefor you need to add Ondrej’s PPA to get the PHP version of your choice:
Install PHP 7.1
Once you enabled the ondrej/php PPA, you can install PHP 7.1 using the below command:To install PHP7.1 including some of the most commonly used modules you can use the following command:
Configur3 PHP
Once the installation is completed you need to edit the php.ini file:Find the php.ini configuration file like below:
You will see the output similar to the following:
Output
Loaded Configuration File: /etc/php/7.1/cli/php.ini
Edit the file using your preferred text editor:
Make the following changes:
Then, restart the PHP-FPM service:
Tried this, but Apache now wont restart since it can't find /usr/lib/apache2/modules/libphp7.1.so
ReplyDeleteTo fix the issue, execute below command:
Delete1. sudo apt-get autoremove
2. sudo add-apt-repository ppa:ondrej/php
3. sudo apt-get update
4. sudo apt-get install php7.1
5. sudo apt-get install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-zip php7.1-fpm php7.1-intl php7.1-simplexml
Restart Apache: