我们在EC2实例上使用aws弹性豆柄作为PHP应用程序。由于我们选择了负载平衡,所以它不断地更改实例。
我在想,如果我们安装了一个PHP插件,它会受到实例更改的影响吗?或者它也会在新的实例中使用?
问这个问题,因为我们观察到每次有弹性豆柄改变的情况,我们的应用程序就会重新部署。
我们需要安装Geoip插件。如何在不影响实例更改的情况下安装它?
发布于 2016-08-10 18:14:59
如果保存env设置,则在执行应用程序时始终具有相同的EC2设置。
我更喜欢使用代码进行这种自定义(您也可以使用AWS控制台来实现这一点)。因此,在源根目录中创建一个文件,其路径如下:具有以下内容的.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的,但是您也可以使用与geoip相同的方法。
有关更多信息:PHP.container.html#php-configuration-namespace
示例来源:http://qpleple.com/install-phpredis-on-amazon-beanstalk/
发布于 2017-03-23 08:10:09
我们为php7使用geoip的工作配置:
.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 restarthttps://stackoverflow.com/questions/38730483
复制相似问题