3

I'm migrating our website from an older Centos server to a new EC2 instance (Amazon Linux 2, aarch64). I'd like to install both the LAMP stack and memcached on the EC2 instance stack; which is the setup we had on our old server

The amzn2extra-php7.4 repo has a package php-pecl-memcached.aarch64, but there is no corresponding package for either amzn2extra-php8.0 or amzn2extra-php8.1

All the guides I have found online are for PHP 7.4 and seem to make use of php-pecl-memcached, and I'd rather not downgrade to a PHP version that is no longer supported

I did find some documentation on how to install the Amazon Elasticache extension, which supports memcached, but that appears to be designed only to connect with a separate managed cluster, and I want to install memcached on the same machine

Is there a workaround?

Arth
  • 415

2 Answers2

3

Since the memcached extension is not available in the Amazon repositories, you'll have to install it from PECL with the procedure below.

Enable Amazon channels:

sudo amazon-linux-extras enable php8.1 memcached1.5
sudo yum update

Install build tools and dependencies:

sudo yum install -y gcc make php php-pear php-devel libmemcached libmemcached-devel zlib-devel memcached

Install the memcached extension from PECL:

sudo pecl update-channels
sudo pecl install memcached

Follow the prompts and instructions on screen (press Enter to use default options).

Activate the extension:

echo extension=memcached.so | sudo tee -a /etc/php.ini
sudo systemctl restart httpd

Now confirm that the extension is loaded

php --info | grep "memcached support"

Please note that all this gives you is an unsupported memcached extension and you are in charge of installing security updates for it from now on.

In a production environment I would strongly prefer the Ubuntu image instead, where apt install php8.1-memcached memcached installs the same thing and it gets automatic security updates.

Sergiu
  • 86
0

Based on Sergiu's response I also need the php-igbinary extension:

pecl update-channels

pecl install igbinary echo extension=igbinary.so | sudo tee -a /etc/php.ini

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="yes" enable-memcached-session="yes"' memcached echo extension=memcached.so | sudo tee -a /etc/php.ini

sudo systemctl restart httpd

Confirm that both extensions are loaded

php --info | grep "memcached support"
php --info | grep "igbinary"