PHP 7.1, which has new properties and performance upgrades is available for a while. But most of the distros still does not have the PHP 7.1 packages on the repositories. On this post you will find how to install PHP 7.1. on Debian and Ubuntu.
Attention some plugins or some themes with particular frameworks may not work correctly in WordPress with this new version.
Uninstalling PHP 7.0
If you already have installed PHP 7.0, first you have to uninstall it by typing:
1 |
apt-get purge 'php7*' |
Adding Repository for Ubuntu 14.04 – 16.10
First we have the install add the repository which Ondrej Sury created for PHP 7.1 users.
1 2 |
sudo add-apt-repository ppa:ondrej/php sudo aptget update |
Addinig Repository for Debian 8
Adding repository to Debian is a bit different. Here are the commands to add the repository to Debian 8:
1 2 3 4 |
apt-get install apt-transport-https lsb-release ca-certificates wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list apt-get update |
Now we can install PHP 7.1
Nginx
With the command below, you can easily install PHP 7.1 with some dependencies, if you will run Nginx as the web server:
1 |
apt install --no-install-recommends php7.1 php7.1-fpm php7.1-mysql php7.1-curl php7.1-json php7.1-gd php7.1-mcrypt php7.1-msgpack php7.1-memcached php7.1-intl php7.1-sqlite3 php7.1-gmp php7.1-geoip php7.1-mbstring php7.1-redis php7.1-xml php7.1-zip |
Don’t forget to modify your configuration file.
1 |
/etc/php/php7.1-fpm.sock |
Apache
And here is the command for Apache web server:
1 |
apt install --no-install-recommends php7.1 libapache2-mod-php7.1 php7.1-mysql php7.1-curl php7.1-json php7.1-gd php7.1-mcrypt php7.1-msgpack php7.1-memcached php7.1-intl php7.1-sqlite3 php7.1-gmp php7.1-geoip php7.1-mbstring php7.1-redis php7.1-xml php7.1-zip |