Open sunaoka opened 2 years ago
at least libmemcached package should be available to be able to easily install memcached through
pecl install memcached
We are investigating adding libmemcached-awesome
(so you get the library at least) in a future release. We don't currently have plans to ship pecl packages, but this should enable pecl install of it hopefully
FYI this is what it took me to get it working in an .ebextension
command: |
if [[ $(php -m | grep memcached | wc -l) -eq "0" ]]; then
cd /tmp
wget <your S3 URL>/libmemcached-1.1.4.rpm -O /tmp/libmemcached.rpm
rpm -ihv /tmp/libmemcached.rpm
pecl install --onlyreqdeps --nobuild memcached
cd "$(pecl config-get temp_dir)/redis"
phpize
./configure --disable-memcached-sasl
sudo make
sudo make install
else
echo "memcached allready loaded."
fi
hi @gregnetau, you can also use --configureoptions
if you want to avoid phpize / configure / make lines :
e.g.:
pecl install --configureoptions 'with-libmemcached-dir="no" with-zlib-dir="no" with-system-fastlz="no" enable-memcached-igbinary="yes" enable-memcached-msgpack="no" enable-memcached-json="no" enable-memcached-protocol="no" enable-memcached-sasl="no" enable-memcached-session="no"' memcached
hi @jocel1, I tried your command but its still failing due to requiring the libmemcached directory
checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located
ERROR: `/var/tmp/memcached/configure --with-php-config=/usr/bin/php-config --with-libmemcached-dir=no --with-zlib-dir=no --with-system-fastlz=no --enable-memcached-igbinary=yes --enable-memcached-msgpack=no --enable-memcached-json=no --enable-memcached-protocol=no --enable-memcached-sasl=no --enable-memcached-session=no' failed
The library needs to get added at least for us to build it using pecl.
libmemcached-awesome is available in version 2023.2.20230920. This is how I install it in my LAMP stack CloudFormation UserData.
dnf install -q -y php-devel php-pear gcc
pear update-channels
pecl update-channels
/usr/bin/yes 'no' | pecl install igbinary
echo 'extension=igbinary.so' > /etc/php.d/30-igbinary.ini
/usr/bin/yes 'no' | pecl install msgpack
echo 'extension=msgpack.so' > /etc/php.d/30-msgpack.ini
dnf install -q -y memcached-devel libmemcached-awesome-devel zlib-devel cyrus-sasl-devel libevent-devel
/usr/bin/yes 'no' | pecl install --configureoptions 'enable-memcached-igbinary="yes" enable-memcached-msgpack="yes" enable-memcached-json="yes" enable-memcached-protocol="yes" enable-memcached-sasl="yes" enable-memcached-session="yes"' memcached
echo 'extension=memcached.so' > /etc/php.d/41-memcached.ini
Run the above commands as root
Edit: include igbinary and msgpack
To build on limmike's answer, you also need to install igbinary and msgpack.
My Dockerfile starts with the following:
FROM public.ecr.aws/amazonlinux/amazonlinux:2023.2.20230920.1
# in a few days/weeks, the latest 2023 from docker hub should work fine too:
#FROM amazonlinux:2023
and further down:
# NOTE: Amazon Linux 2023 doesn't include any external php extensions, so
# we have to download and build them ourselves with pear, pecl and gcc:
RUN dnf -y install php8.2-devel php-pear gcc && \
pear update channels && \
pecl update channels && \
\
# build + install igbinary for use by php-memcached
pecl install igbinary && \
echo "extension=igbinary.so" | sudo tee /etc/php.d/20-igbinary.ini && \
\
# build + install msgpack for use by php-memcached
pecl install msgpack && \
echo "extension=msgpack.so" | sudo tee /etc/php.d/20-msgpack.ini && \
\
# build + install php-memcached
dnf install -q -y memcached-devel memcached \
libmemcached-awesome-devel libmemcached-awesome \
zlib-devel zlib cyrus-sasl cyrus-sasl-devel \
libevent libevent-devel && \
pecl install --configureoptions \
'with-zlib-dir="no" \
with-system-fastlz="no" \
with-libmemcached-dir="no" \
enable-memcached-igbinary="yes" \
enable-memcached-msgpack="yes" \
enable-memcached-json="yes" \
enable-memcached-protocol="yes" \
enable-memcached-sasl="yes" \
enable-memcached-session="yes"' memcached && \
echo "extension=memcached.so" | sudo tee /etc/php.d/25-memcached.ini && \
\
# clean up php dev tools and the dnf cache
dnf remove -y gcc php8.2-devel php-pear libzip-devel \
memcached-devel libmemcached-awesome-devel zlib-devel \
cyrus-sasl-devel libevent-devel && \
dnf autoremove -y && dnf clean all && rm -rf /var/cache/dnf
Then when I run phpinfo(), on this image, I get a working php-memcached module:
Confirming that after updating to version 2023.2.20230920 I can now build and install memcached using pecl!
Both instructions from limmike and cbanack works just fine, just make sure you are in the newest version of al2023 mentioned above.
What package is missing from Amazon Linux 2023? Please describe and include package name.
php-pecl-memcached, php-pecl-igbinary
Is this an update to existing package or new package request?
New package request.
Is this package available in Amazon Linux 2?
Yes.
Number of users impacted
More than 1 million users we serve.