Skip to content

Instantly share code, notes, and snippets.

@Comersite
Last active March 3, 2021 10:32
Show Gist options
  • Save Comersite/cc76915a1f6575db741214ff52a09cea to your computer and use it in GitHub Desktop.
Save Comersite/cc76915a1f6575db741214ff52a09cea to your computer and use it in GitHub Desktop.
AWS - Installing the ElastiCache Cluster Client for PHP 7.0
files:
"/home/ec2-user/install-cluster-client.sh":
mode: "000744"
owner: root
group: root
content: |
#!/bin/bash
#hide old ini
if [ -a /etc/php.d/50-memcached.ini ]
then
mv /etc/php.d/50-memcached.ini /etc/php.d/50-memcached.ini.disabled
fi
#get cluster
wget http://elasticache-downloads.s3.amazonaws.com/ClusterClient/PHP-7.0/latest-64bit -O /tmp/AmazonElastiCacheClusterClient-latest-PHP70-64bit.zip
#uninstall old version (can fail - is ok)
pecl7 uninstall __uri/AmazonElastiCacheClusterClient
#unzip cluster
unzip /tmp/AmazonElastiCacheClusterClient-latest-PHP70-64bit.zip
#move module
mv /etc/artifact/amazon-elasticache-cluster-client.so /usr/lib64/php/7.0/modules/amazon-elasticache-cluster-client.so
chmod +x /usr/lib64/php/7.0/modules/amazon-elasticache-cluster-client.so
#remove where client is stuck in wrong place in ini file
sed -i '/extension="amazon-elasticache-cluster-client.so"/d' /etc/php.ini
#make correct ini (done as separate file in .ebextensions)
#echo "extension=amazon-elasticache-cluster-client.so" | tee /etc/php.d/memcached.ini
"/etc/php.d/memcached.ini":
mode: "000644"
owner: root
group: root
content: |
extension=amazon-elasticache-cluster-client.so
;standard settings from 50-memcached
[memcached]
memcached.sess_locking = On
memcached.sess_lock_wait = 150000
memcached.sess_lock_max_wait = 0;
memcached.sess_lock_expire = 0;
memcached.sess_prefix = "memc.sess.key."
memcached.sess_consistent_hash = Off
memcached.sess_remove_failed = 1
memcached.sess_number_of_replicas = 0
memcached.sess_binary = Off
memcached.sess_randomize_replica_read = Off
memcached.sess_connect_timeout = 1000
memcached.sess_sasl_username = NULL
memcached.sess_sasl_password = NULL
memcached.compression_type = "fastlz"
memcached.compression_factor = "1.3"
memcached.compression_threshold = 2000
memcached.serializer = "igbinary"
memcached.use_sasl = Off
memcached.store_retry_count = 2
commands:
"01":
command: sudo yum -y install memcached
"02":
command: /home/ec2-user/install-cluster-client.sh
"03":
command: sudo /etc/init.d/memcached start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment