How To Install Memcached on AlmaLinux 9

In this guide, we want to teach you How To Install and Configure 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.

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
Output
memcached configure 1.6.17
generated by GNU Autoconf 2.71

Copyright (C) 2021 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.

How To connect to the Memcached

For connecting 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.

Hope you enjoy it.

You may be 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

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!