AWS Elastic Beanstalk Installing IonCube or Zend Loader

余生长醉 提交于 2019-12-05 19:21:17

This installation for IonCube worked just now for EC2 (hope it works as well for elastic beanstalk):

PHP version installed is 5.5 - please change the 5.5 to your installed version if you have a different one ("php -v" gives you the currently installed one):

# Download current version of IonCube loader
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

# Unzip to /usr/local
sudo tar -xzf ioncube_loaders_lin_x86-64.tar.gz -C /usr/local

# Add installed module to PHP config
echo 'zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.5.so' | sudo tee /etc/php-5.5.d/ioncubeloader.ini

# Restart Apache (if necessary)
sudo service httpd restart

If your run "php -v" now, it should show you IonCube installed:

PHP 5.5.12 (cli) (built: May 20 2014 22:27:36) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with the ionCube PHP Loader v4.6.1, Copyright (c) 2002-2014, by ionCube Ltd., and
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
AaronHatton

I spent several hours on this and found I had silly mistakes like typos, improper YAML file formatting etc. and have found the following solution.

Within your app deployment folder you need to create an .ebextensions folder, let's say the folder structure is as follows:

  • /Web/
    • index.php
    • phpinfo.php
    • .htaccess
    • /.ebextensions/

Within the .ebextensions folder you will need to create a configuration package, for my example I am using Amazon AMI Linux with PHP 5.6 installed through Amazon Elastic Beanstalk.

A link for more information can be found here: Customizing Software on Linux Servers

Create a file called ioncube.config with the following contents:

commands:
  install-ioncube:
    command: |
      if [ ! -f /etc/php.d/ioncube.ini ]; then
          mkdir /tmp/ion && cd /tmp/ion
          wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
          tar xzvf ioncube_loaders_lin_x86-64.tar.gz
          mv /tmp/ion/ioncube/ioncube_loader_lin_5.6.so "/usr/lib64/php/5.6/modules/ioncube_loader_lin_5.6.so"
          touch /etc/php.d/01-ioncube.ini
          echo "zend_extension=/usr/lib64/php/5.6/modules/ioncube_loader_lin_5.6.so" > /tmp/ioncube.ini
          mv /tmp/ioncube.ini /etc/php.d/01-ioncube.ini
      fi

NOTE: When you copy this, you will need to ensure the formatting is spaces and not tabs for it to be a properly formatted YAML file.

Create another file called zenframework.config with the following contents

packages: 
  yum:
    php-ZendFramework: []

I found that without these two it did not work as expected, I also had an issue where for some unknown reason my .ebextensions folder was being ignored, if this happens to you simply rename it to something else and back again.

Run the eb deploy from the Amazon CLI and then take a look at the PHP configuration, if unsure this can be checked with the following code:

<?php

    phpinfo();

<?php

This should now be installed. If you need to know more information on the Amazon CLI it can be installed using this guide: Installing the EB Command Line Interface (CLI) and then the guide on working with PHP within Elastic Beanstalk is found here: Deploying Elastic Beanstalk Applications in PHP

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!