如何通过Amazon AWS Elastic Beanstalk安装PHP扩展? [英] How to install a PHP extension witn Amazon AWS Elastic Beanstalk?

查看:132
本文介绍了如何通过Amazon AWS Elastic Beanstalk安装PHP扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在我们的EC2实例上的PHP应用程序中使用了aws Elastic beantalk。由于我们选择了负载平衡,因此它会不断更改实例。

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.

我想知道我们是否安装了PHP插件,它会受到实例更改的影响吗?

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?

问这个问题是因为我们发现每次实例被弹性beantalk更改时,我们的应用程序都被重新部署。

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

我们需要安装 Geoip 插件。如何在不影响实例更改的情况下安装它?

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

推荐答案

如果保留env设置,则始终保持相同执行应用程序时的EC2设置。

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

我更喜欢使用代码进行这种自定义(您也可以使用AWS控制台进行此操作)。因此,使用以下路径在源根目录中创建一个文件:
.ebextensions / php-modules.config ,其中包含以下内容(ps:我正在生产中使用它,没有问题):

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):

commands:
    01_redis_install:
        # run this command from /tmp directory
        cwd: /tmp
        # don't run the command if phpredis is already installed (file /etc/php.d/redis.ini exists)
        test: '[ ! -f /etc/php.d/redis.ini ] && echo "redis not installed"'
        # executed only if test command succeeds
        command: |
            wget https://github.com/nicolasff/phpredis/zipball/master -O phpredis.zip \
            && unzip -o phpredis.zip \
            && cd phpredis-phpredis-* \
            && phpize \
            && ./configure \
            && make \
            && make install \
            && echo extension=redis.so > /etc/php.d/redis.ini

这是用于安装php-redis,但您可以

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

有关更多信息: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.container.html#php-configuration-命名空间

示例来源: http://qpleple.com/install-phpredis-on-amazon-beanstalk/

这篇关于如何通过Amazon AWS Elastic Beanstalk安装PHP扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆