AMI - upgrade PHP from 7.1 to 7.3

AMI - upgrade PHP from 7.1 to 7.3
PHP logo

Don't do this on a production system

I ran this on an Amazon Linux AMI - it's probably fine on CentOS, etc.

Get all the PHP 7.1 packages and make a file called php. You might have to change the .x86_64 to .i386/.i686

sudo yum list installed php71* | grep php | cut -f1 -d' ' | tr -d '.x86_64' | tr "\n" ' ' | sed "s/71/73/g" > php

Remove PHP 7.1 (remember I said not to do this on a production machine)

sudo yum remove php71*

Now edit your php file and add

sudo yum install at the beginning of the list of packages

It should look something like this

sudo yum install php73 php73-cli php73-common php73-gd php73-imap php73-intl php73-json php73-mbstring php73-mysqlnd php73-opcache php73-pdo php73-pecl-apcu php73-pecl-igbinary php73-pecl-memcached php73-pgsql php73-process php73-soap php73-ml

Run the php file with

source php

And, if you are using memcached, run this too

sudo yum install php7-pear php73-devel
sudo pecl7 install memcached
sudo pecl7 update-channels

Add this into php.ini somewhere ...

Restart Apache

sudo apachectl restart

Bask in the glory