installing PHP module from Elastic Beanstalk

amazon-elastic-beanstalk, mongodb, php

Solution

I have figured it out and thought I would share what I found. Thanks to Hudku (http://blog.hudku.com/2013/02/innocuous-looking-evil-devil.html#elastic-beanstalk.config) for the excellent article:

1) Create myapp.config 2) enter the following into it

packages:
    yum:
        dos2unix: []


container_commands:
    01-command:
        command:        rm -rf /myapp/ebextensions

    02-command:
        command:        mkdir -p /myapp/ebextensions

    03-command:
        command:        cp -R .ebextensions/* /myapp/ebextensions/

    04-command:
        command:        dos2unix -k /myapp/ebextensions/mongo.sh

    05-command:
        command:        chmod 700 /myapp/ebextensions/mongo.sh

    06-command:
        command:        bash /myapp/ebextensions/mongo.sh

Then create mongo.sh file and put in it something like:

#!/bin/bash

if [ ! -f /mongostatus.txt ];
then
    pecl install mongo
    echo "mongo extension installed" > /mongostatus.txt
    apachectl restart
fi

This will install mongo php extension and restart apache so the install takes affect.

Problem

I am trying to configure my AWS Elastic Beanstalk to work with mongo, all I need to do is install the mongo driver for PHP and update the php.ini file To do this, usually I would ssh into the EC2 and run: ``` sudo pecl install mongo ``` But this would require using a custom AMI which isnt the best way to go. It is better to use config files to install the software required onto the standard AMI. So to do this, I have done the following: created directory .ebextensions created file mongo.config in it I have put the following: ``` packages: pecl: install mongo ``` However upon deployment, I get the following error: ``` "option_settings" in one of the configuration files failed validation. More details to follow. ``` and ``` 'null' values are not allowed in templates ``` So I am wondering how this config file needs to be laid out in order to install the mongo extension? I have read the info here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html but I am not quite understanding how to do this specific task Help would be appreciated , thanks! :)

Original source