Skip to content

Instantly share code, notes, and snippets.

@strategio
Last active May 19, 2024 15:54
Show Gist options
  • Save strategio/797087099cea854f1b614a8f81be2935 to your computer and use it in GitHub Desktop.
Save strategio/797087099cea854f1b614a8f81be2935 to your computer and use it in GitHub Desktop.
Setup memcached in a Local by Flywheel site
#!/usr/bin/env bash
PHP_VERSION=$1
CONF_FOLDER="/conf/php/${PHP_VERSION}/"
PHP_INI="${CONF_FOLDER}php.ini"
apt-get -y update
apt-get -y install memcached
service memcached start
# Now for installing php 7 memcached extension
apt-get -y install build-essential pkg-config git autoconf
apt-get -y install libmemcached-dev libmsgpack-dev libmsgpackc2
cd ${CONF_FOLDER}
git clone --depth 1 https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
/opt/php/${PHP_VERSION}/bin/phpize
./configure --with-php-config=/opt/php/${PHP_VERSION}/bin/php-config
make install
make test
# Include memcached in php.ini
echo "[memcached]" >> ${PHP_INI}
echo "extension = ${CONF_FOLDER}/php-memcached/modules/memcached.so" >> ${PHP_INI}
@michael-sumner
Copy link

michael-sumner commented May 17, 2024

@strategio I'm curious where did you run this script? Is it in the Local site's /app/public directory, or elsewhere?

Note: I'm seeing the following missing variables. This is the output:

Setting Local environment variables...
----
WP-CLI:   WP-CLI 2.9.0
Composer: 2.6.2 2023-09-03
PHP:      8.1.23
chMySQL:    mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /bin/zsh ...
❯ chmod +x ./activate-memcached.sh
❯ ./activate-memcached.sh
./activate-memcached.sh: line 8: apt-get: command not found
./activate-memcached.sh: line 9: apt-get: command not found
./activate-memcached.sh: line 10: service: command not found
./activate-memcached.sh: line 14: apt-get: command not found
./activate-memcached.sh: line 15: apt-get: command not found
./activate-memcached.sh: line 17: cd: /conf/php//: No such file or directory
Cloning into 'php-memcached'...
remote: Enumerating objects: 197, done.
remote: Counting objects: 100% (197/197), done.
remote: Compressing objects: 100% (177/177), done.
remote: Total 197 (delta 40), reused 78 (delta 20), pack-reused 0
Receiving objects: 100% (197/197), 141.57 KiB | 4.29 MiB/s, done.
Resolving deltas: 100% (40/40), done.
./activate-memcached.sh: line 20: /opt/php//bin/phpize: No such file or directory
./activate-memcached.sh: line 21: ./configure: No such file or directory
make: *** No rule to make target `install'.  Stop.
make: *** No rule to make target `test'.  Stop.
./activate-memcached.sh: line 27: /conf/php//php.ini: No such file or directory
./activate-memcached.sh: line 28: /conf/php//php.ini: No such file or directory

@strategio
Copy link
Author

Hi @michael-sumner!
Sorry but this snippet is 5 years old and I didn't even remember it existed...
And now I don't use Local anymore.

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