Upgrade (cleanly) from PHP 7.0 to PHP 7.1

Invoice Ninja Ubuntu – PHP 7.0 upgrade guide.

PHP 7.0 is now EOL, so time to upgrade!

You could move straight up to the latest PHP which at the time of writing is 7.2, however for our application stack, we will only be moving to 7.1

The first thing that needs to be done is all your NGINX configs need to point to the new FPM process, simply sed the conf files replacing 7.0 with 7.1

find . -type f -exec sed -i 's/7.0/7.1/g' {} \;

Next install all the required PHP libs

sudo apt install php7.1 php7.1-bz2 php7.1-cli php7.1-common php7.1-curl php7.1-fpm php7.1-gd php7.1-gmp php7.1-intl php7.1-json php7.1-mbstring php7.1-mysql php7.1-opcache php7.1-readline php7.1-xml php7.1-xmlrpc php7.1-zip

Now lets start up the 7.1 service

sudo service php7.1-fpm start

Lets restart NGINX so that it picks up the new PHP 7.1 fpm process

sudo service nginx restart

And now lets get rid of the old PHP version

sudo apt-get purge php7.0 php7.0-common

Bonus points –

Remember your PHP version is now referencing a new PHP.ini file… make sure you bring across all your required changes such as session handlers etc etc

sudo vim /etc/php/7.1/fpm/php.ini

[Session]
session.save_handler = redis

session.save_path = "tcp://redis_server_here"

Comments are closed.