Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bash script to install memcache on AWS lightsail LAMP stack (Mar 2017)
#!/bin/bash
#install memcache on AWS lightsail bitnami
#memcache (no "d") is handy for cross platform testing as it will work on windows
#WAMP etc. where the memcached version does not appear to have a windows port)
#(lightsail lamp has the build environment gcc etc. already installed)
#memcache version
VERSION='3.0.8'
cd /root/bitnami
wget http://pecl.php.net/get/memcache-${VERSION}.tgz
tar -zxf memcache-${VERSION}.tgz
export PHP_AUTOCONF=/usr/bin/autoconf
export PHP_PREFIX=/opt/bitnami/php
cd memcache-${VERSION}
/opt/bitnami/php/bin/phpize
./configure --enable-memcache --with-zlib-dir=/opt/bitnami/common
make
sudo make install
cd ..
rm -rf memcache-${VERSION}
rm memcache-${VERSION}.tgz
#enable
sudo perl -pi -e 's/^;extension=memcache.so/extension=memcache.so/' /opt/bitnami/php/etc/php.ini
#install the memcached daemon (defaults are ok for testing -m 64 -p 11211 -u memcache -l 127.0.0.1)
sudo apt-get install memcached
sudo /etc/init.d/memcached start
#don't forget to restart fpm or you will go nuts chasing why it doesn't work...
sudo /opt/bitnami/ctlscript.sh restart apache
sudo /opt/bitnami/ctlscript.sh restart php-fpm
#done
#In php:
#$memcacheObj = new Memcache;
#$memcacheObj->addServer('127.0.0.1', 11211);
#...and you are off to the races
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.