[Selfhosting] Enabling PHP 7.1 on AMIMOTO AMI (HVM/PVM)

Target AMI:

 

Note

We firmly recommend creating snapshot before start to upgrade for fail safe.

Check out our document How to Create a Snapshot and Restore from it. If you want to automate creating a snapshot, you'll need some additional modifications. For more details, check our document: How to Automatically Create a Snapshot

 

 

Steps

There are two ways to update your PHP version to 7
(A) Upgrade to PHP 7.1 when you launch new instance
(B) Upgrade to PHP 7.1 on your running instance

 

 

(A) Upgrade to PHP 7.1 when you launch new instance

On the step3 of starting the instance process, you will see Configure Launch Instance Details. Input the following command into UserData (red rectangle) of Advanced Details in the bottom of this page.

For more details of UserData, check our official document: Running Commands on Your Linux Instance at Launch

Copy below and paste into UserData.

#!/bin/bash -ex

echo '{"phpfpm":{"enabled": true, "version":"71"}}' > /tmp/php-fpm-71.json
if [ ! -e /opt/local ]; then
/bin/mkdir -p /opt/local
fi

if [ -f /opt/local/amimoto.json ]; then
hash jq || /usr/bin/yum install -y jq
/usr/bin/jq -s '.[1] * .[0]' /tmp/php-fpm-71.json /opt/local/amimoto.json > /tmp/amimoto.json
/bin/mv -f /tmp/amimoto.json /opt/local/amimoto.json
else
/bin/cp /tmp/php-fpm-71.json /opt/local/amimoto.json
fi
/bin/rm -f /tmp/php-fpm-71.json

 

 

 

 

(B) Upgrade to PHP 7.1 on your running instance

Note: we recommend creating a snapshot of your instance before your working through it.

  1. Check the version of configuration files of AMIMOTO AMI, if necessary, update them;
  2. Update PHP version to 7.1 using modified chef recipe;
1. Check the version of configuration files of AMIMOTO AMI, if necessary, update them.

Run the following command after you succeeded access to the server.

$ git -C /opt/local/chef-repo/cookbooks/amimoto/ branch
* master

This command shows you the version of configuration files of AMIMOTO AMI.

In case version is * 2016.01.

You can update your PHP version to 7.1 using following command and steps:

$ curl -L -s https://raw.githubusercontent.com/amimoto-ami/amimoto-update/master/amimoto_update.2016.01.sh | sudo bash
$ sudo reboot

 

In case the version is the other than 2016.01 (e.g., master or 2015.01 ) or you've got an error.

Update your AMIMOTO AMI to the latest with the following command.
Note: the command replaces and overwrites packages of PHP and MySQL which you installed manually.
If you don't want to overwrite PHP and MySQL, you'd better launch the latest AMIMOTO AMI, update the PHP version 7 and migrate into it.

$ curl -L -s https://raw.githubusercontent.com/amimoto-ami/amimoto-update/master/amimoto_update.sh | sudo bash

$ sudo reboot

 

 

 

2. Upgrade the PHP to the version 7.1 using modified configuration file

Ater the instance is starting up, ssh access to it, then run the following command:

$ ssh -i PATH-TO-KEY-FILE.pem ec2-user@IP-ADDRESS-OF-YOUR-INSTANCE
$ sudo su - # yum update -y # cd /opt/local/chef-repo/cookbooks/amimoto # git pull origin 2016.01 # cd /opt/local # echo '{"phpfpm":{"enabled": true, "version":"71"}}' > /tmp/php-fpm-71.json # hash jq || yum install -y jq # jq -s '.[1] * .[0]' /tmp/php-fpm-71.json /opt/local/amimoto.json > /tmp/amimoto.json # mv -f /tmp/amimoto.json /opt/local/amimoto.json # /opt/local/provision
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk