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! :)
pecl
is not a valid package manager on Amazon Linux and therefore cannot be used under the packages
key of an .ebextensions
config.
To install a PECL package it is enough to add a single command under the commands
key. To avoid that Beanstalk tries to install the extension twice on follow-up deployments add a PHP console command to the test
key that checks if the extension is already installed:
commands:
install_mongo_driver:
command: pecl install mongo
test: "php -r \"exit(extension_loaded('mongo') ? 1 : 0);\""
If the test
result is true
, i.e. exit(0)
, then the command
gets executed - otherwise not. Please note that a exit code of 0
means "No errors" in a shell context.
See also the description at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With