Php – Installing mongo on AWS Elastic Beanstalk

amazon-web-servicesPHP

I am running elastic beanstalk on AWs. using 64bit unix php 5.3.

I am wanting to install mongo driver so php will talk to mongo.

the usual command is:

sudo pecl install mongo

According to AWS support, the way to do it is via a .config file in .ebextensions. I cont seem to figure out the format that it needs to be in order to run a script to do it.

the script i am writing looks like this:

#!/bin/bash
sudo pecl install mongo

and the .config file I have looks like:

container_commands:
 command:
    command:        bash .ebextensions/mongo.sh

I must be doing it quite wrong because each time I try to deploy, it errors on trying to run the command.

The end result I want it to have mongo php extension installed using the .config method

Thanks for your help

Best Answer

I accomplished this creating a config file with this content:

container_commands:
  01installMongoExtension:
    command: 'printf "\n" | pecl install -f mongo'
    ignoreErrors: true

And it worked, but I am not sure if elasticbeanstalk is installing the extension every time I deploy a new version of my application.

Edit: now when you try to install the mongo extension through pecl it asks a question (Build with Cyrus SASL?). So you have to answer to the question automatically, that's why you have to use printf.