How to install a PHP extension witn Amazon AWS Elastic Beanstalk?

Question:

We are using aws elastic beanstalk for our PHP application on EC2 instance. Since we opted for load balancing, it keeps changing the instance time and again.

I am wondering if we install a PHP plugin, will it be affected by change of instance or it will be available in new instance as well?

Asking this question because we have observed everytime instance is changed by elastic beanstalk, our application is redeployed.

We need to install Geoip plugin. How to install it without affecting it on instance change ?

Answer:

If you keep the env settings saved, you will always have the same EC2 settings when executing your app.

I prefer to do this kind of customizing using code (you can do this using the AWS Console too). So, create a file in your source root, with the following path:
.ebextensions/php-modules.config with these contents (ps: I’m using this in production with no problem):

This is for install php-redis, but you can use the same approach to geoip as well.

For more information: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.container.html#php-configuration-namespace

Source of the example: http://qpleple.com/install-phpredis-on-amazon-beanstalk/

Leave a Reply