Skip to content

Instantly share code, notes, and snippets.

@nmcgann
Created January 13, 2016 09:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmcgann/c041b3a19b540ae31b8d to your computer and use it in GitHub Desktop.
Save nmcgann/c041b3a19b540ae31b8d to your computer and use it in GitHub Desktop.
AWS Elastic Beanstalk .ebextensions config to install Elasticache memcached cluster client (PHP 5.6)
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
#fetch client
wget http://elasticache-downloads.s3.amazonaws.com/ClusterClient/PHP-5.6/latest-64bit -O /tmp/AmazonElastiCacheClusterClient-latest-PHP56-64bit.tgz
#uninstall old version (can fail - is ok)
pecl uninstall __uri/AmazonElastiCacheClusterClient
#install new
pecl install /tmp/AmazonElastiCacheClusterClient-latest-PHP56-64bit.tgz
#move module to correct place
mv /root/pear/ext/amazon-elasticache-cluster-client.so /usr/lib64/php/5.6/modules/amazon-elasticache-cluster-client.so
chmod +x /usr/lib64/php/5.6/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: /home/ec2-user/install-cluster-client.sh
@nmcgann
Copy link
Author

nmcgann commented Jan 13, 2016

memcached parameters need adjusting (e.g. sess_consistent_hash) - these are the defaults from 50-memcached.ini.

This is a minimum viable version - bash script could be elaborated with more error checking etc.

@Comersite
Copy link

Hello!
And for PHP 7 version how to proceed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment