How do upgrade to php 7.1?



I have tried numerous different ways to upgrade php to 7.1. I have followed loads of guides, community tutorials etc but I always end up with some kind of error that makes no apparent sense. Is there not a straight forward way of upgrading php?


sudo apt-get purge 'php7*'
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install -y 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 php7.1-imagick


I used this on a fresh new C9 container, and it messed up everything. Database gone, phpmyadmin gone. Moreover, can’t reinstall them either.