I am trying to deploy a php application on Elastic Beanstalk. Everything is working fine except from my calls to the mongo driver.
My attempt to install it followed these steps (unsuccessfully):
sudo yum install php-devel (for phpize)sudo pecl install mongofollow instructions to try command: sudo echo "extension=mongo.so" >> /etc/php.ini with
failure. error message is:
-bash: /etc/php.ini: Permission denied
Am I going about this the right way?
You should not SSH into Elastic Beanstalk to install php-devel and mongo. Those settings will disappear when your EB environment scales in/out or server crash by accident.
Try to use Configuration File to customize your EB Environment.
/your_app/.ebextensions/01install_mongo_driver.config.Type the following inside the configuration file 01install_mongo_driver.config to install php mongodb driver.
commands:
install_mongo_driver_command:
command: pecl install mongo
Because PHP 5.4 on 64bit Amazon Linux 2013.09 AMI already contained php-devel, so you won't install it manually.
files:
"/etc/php.d/99mongo.ini" :
mode: "000755"
owner: root
group: root
content: |
extension=mongo.so
commands:
install_mongo_driver_command:
command: sudo pecl7 install mongodb
ignoreErrors: true
Above adds enables the extension on php.ini and installs mongodb for your PHP. The ignore errors prevents any error if installing a second time. (e.g. if your server crashes and has to reboot). This is to prevent an error that "mongodb is already installed"
Note: this file is stored in: /your_app_root/.ebextensions/mongo.config
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