1

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
  • 365
  • 1
  • 5
  • 15

1 Answers1

1

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
  • 66
  • 3
  • Thanks, beat me to it - I ended up doing something similar, it's a shame that the amazon repos are missing this stuff – Arth Jan 17 '23 at 14:09