Install Memcached on AlmaLinux 9 | Free Memory Cache

In this guide on the Orcacore website, we want to teach you How To Install Memcached on AlmaLinux 9. Memcached is a free and open-source high-performance memory caching system. It’s typically used to cache database data, API calls, or page rendering chunks in RAM to increase the application’s performance.

It can store data as little as a number, or as big as a finished HTML page. The system is designed to be accessed through TCP so it can work in a separate server, and can also be distributed among several servers, summing up a giant hash table to store data.

When running out of space, the older data is overwritten. So it must be treated as a transitory (not-persisted) cache, meaning that your data may not still be there.

Steps To Install and Configure Memcached on AlmaLinux 9

To complete this guide, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

1. Install Memcached on AlmaLinux 9

By default, Memcached packages are available in the default AlmaLinux repository. But in this guide, we will install Memcached in the latest release from the source.

First, update your local package index with the following command:

sudo dnf update -y

Then, run the following command to install the required packages and dependencies:

sudo dnf install -y tar gcc libevent libevent-devel

Download the Memcached Source package

Now visit the Memcached downloads page and download the latest stable Memcached tar.gz package by using the following command:

sudo wget https://memcached.org/files/memcached-1.6.17.tar.gz

When your download is completed, extract your downloaded file with the command below:

sudo tar -zxf memcached-1.6.17.tar.gz

Then, use the following command to move your extracted file to the /opt directory:

sudo mv memcached-1.6.17 /opt

Build and Install Memcached

At this point, you need to build and install your Memcached service on AlmaLinux 9.

First, switch to your Memcached directory:

cd /opt/memcached-1.6.17/

Then, run the command below to configure your build process:

sudo ./configure --prefix=/usr/local/memcached

Now use the following commands to install Memcached:

# sudo make
# sudo make install

Verify your Memcached installation by using the following command:

./configure --version
Install Memcached on AlmaLinux 9

2. How To Connect to the Memcached?

To Connect to the Memcached server, you need to use a language-specific client.

To use Memcached as a caching database for your PHP application, you need to install the Memcached PHP extensions with the following command:

sudo dnf install php-pecl-memcache

If you are running a Python application, you can install your preferred library with the pip command:

pip install pymemcache
pip install python-memcached

Conclusion

At this point, you have learned to install Memcached on AlmaLinux 9. Memcached is used on AlmaLinux 9 to improve application performance by caching frequently accessed data in RAM. It reduces database load, speeds up dynamic web applications, and enhances scalability.

Hope you enjoy it. You may also like these articles:

Install and Configure Memcached on Debian 11

How to Install and Configure Memcached on CentOS 7

Install and Configure Memcached on Ubuntu 20.04

FAQs

What is Memcached?

Memcached is an open-source, high-performance caching system that stores frequently accessed data in RAM, reducing database load and improving application speed.

What is the default port for Memcached?

Memcached listens on port 11211 by default.

How much memory does Memcached use?

By default, Memcached uses 64MB of RAM. You can increase it by modifying the -m option in /etc/sysconfig/memcached.

Share your love

Stay informed and not overwhelmed, subscribe now!