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

Target AMI:

 

Steps

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

 

(A) Update to PHP 7 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":{"version":"70"}}' > /tmp/php-fpm-70.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 '.[0] * .[1]' /tmp/php-fpm-70.json /opt/local/amimoto.json > /tmp/amimoto.json
/bin/mv -f /tmp/amimoto.json /opt/local/amimoto.json
else
/bin/cp /tmp/php-fpm-70.json /opt/local/amimoto.json
fi
/bin/rm -f /tmp/php-fpm-70.json

 

(B) Update to PHP 7 on your running instance

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

  1. Check the version of configuration files of AMIMOTO AMI, if necessary, update them;
  2. Update PHP version to 7 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 with * in front of it (* 2016.01).

You can update your PHP to PHP7 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 (master, 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 with modified configuration files of AMIMOTO AMI

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":{"version":"70"}}' > /tmp/php-fpm-70.json # hash jq || yum install -y jq # jq -s '.[0] * .[1]' /tmp/php-fpm-70.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

Article is closed for comments.
Powered by Zendesk