Install Memcached on Amazon Linux

Memcached is a tool designed to enhance the performance of dynamic web applications by reducing the database load. The following steps have been verified on an Amazon Linux EC2 Instance running PHP version 8.1.12. Please note that the steps may vary depending on the version of PHP that you are using.

Step 1: Install Memcached Package

sudo yum install memcached

Step 2: Check PHP Version

php -v

Step 3: Install PHP Module

sudo yum install php-memcached

Step 4: Open configuration file and configure memcache

vim /etc/sysconfig/memcached

You can increase MaxCONN and CacheSize value

LISTEN="127.0.0.1"
PORT="11211"
USER="memcached"
MAXCONN="2048"
CACHESIZE="1024"
OPTIONS="-l 127.0.0.1,::1"

Step 5: Enable Memcache

sudo systemctl enable memcached

Step 6: Restart EC2 Instance

service httpd restart

Step 7: Restart Memcache service

service memcached restart

Step 8: Monitor your memcached instance

sudo watch -td '(echo stats ; echo quit) | nc 127.0.0.1 11211 '
Sat, 02/18/2023 - 22:09
Tarun Goswami is a highly experienced professional, currently serving as Technical Lead at a well-established IT services company. With over 12 years of experience across multiple domains, he demonstrates his expertise and passion for the industry through his engaging and informative blog writing in his spare time.
Tags

Comments