2016-08-02 15 views
2

EC2インスタンスのPHPアプリケーションにaws elastic beanstalkを使用しています。ロード・バランシングを選択したので、インスタンスの時間を変更し続けます。Amazon AWS Elastic BeanstalkにPHP拡張モジュールをインストールするには?

私はPHPプラグインをインストールすれば、それはインスタンスの変更の影響を受けるか、新しいインスタンスでも利用できるのでしょうか?

私たちは毎回のインスタンスが弾力のあるバーストークによって変更されているのを観察したのでこの質問をすると、私たちのアプリケーションは再配布されます。

Geoipプラグインをインストールする必要があります。インスタンスの変更に影響を与えずにインストールするには?

+0

カスタムAMIを使用していますか? –

+0

いいえ、アプリのデプロイ中にフリー層に含まれていたすべてのデフォルトを選択しました。 – user2053100

答えて

1

env設定を保存したままにすると、アプリの実行時に常に同じEC2設定になります。

コードを使用してこのようなカスタマイズを行うことをお勧めします(これはAWS Consoleでも可能です)。だから、次のパスで、ソースのルートにファイルを作成します。 .ebextensions/PHP-modules.configをこれらのコンテンツ(PS:私は何の問題もなく生産でこれを使用しています):で

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をインストールするためのものですが、同様の方法でジオープすることもできます。詳細については

:例のhttp://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.container.html#php-configuration-namespace

出典:PHP7のためのGeoIPとhttp://qpleple.com/install-phpredis-on-amazon-beanstalk/

0

私たちの作業構成:

.ebextensions/PHP-modules.config

commands: 
    01_geoip_install: 
     # run this command from /tmp directory 
     cwd: /tmp 
     # don't run the command if php-geoip is already installed 
     test: '[ ! -f /usr/lib64/php/7.0/modules/geoip.so ] && echo "geoip is not installed"' 
     # executed only if test command succeeds 
     command: | 
      yum install -y geoip geoip-devel \ 
      && cd /tmp \ 
      && wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz \ 
      && gunzip ./GeoIP.dat.gz \ 
      && rm /usr/share/GeoIP/GeoIP.dat \ 
      && mv ./GeoIP.dat /usr/share/GeoIP/GeoIP.dat \ 
      && pecl7 install geoip-1.1.1 \ 
      && service httpd restart 
1

YAML

packages: 
    yum: 
     php70-pecl-redis.x86_64: [] 
関連する問題