Install and Configure Memcached on Rocky/Alma Linux

Performance is everywhere, especially when it comes to websites. Website speed and its performance are the most crucial ranking factors. A well-performing website not only gets ranked higher but also has higher conversion rates which means higher revenue. Here in this tutorial let’s see how we can Install and Configure Memcached on Rocky/Alma Linux which will give a good amount of performance boost to our website.

Install-configure-Memcached-on-Rocky-Alma-Linux

Besides Redis, Memcached is another memory object caching system that is free to use and open source. Memcached is developed especially to boost the performance of dynamic web applications. So, it is highly recommended for Bloggers, News websites, e-commerce, and others. The design of Memcached is very simple making it easily adaptable.

I have tested Redis as well as Memcached on Swiftguides. I found Memcached to be more stable in terms of performance. I guess that’s the reason why big internet companies like Facebook, YouTube, OpenStack, and Pinterest use Memcached on their servers.

Here is a complete and easy guide to configuring Memcached

Step 1 – Install Memcached

The first step is to install Memcached. You can just copy and paste the given below command

$ sudo dnf install memcached -y

You can check the Memcached installed version using

$ memcached --version

Step 2 – Start and Enable Memcached Service

Right after installing, the service is in a stop state. Start the service using the command below

$ sudo systemctl start memcached

Now, enable the service

$ sudo systemctl enable memcached

Step 3 – Add and allow Memcached from the Firewall

Memcached runs on port 11211, so to access the service from localhost we will allow it from Firewall

$ sudo firewall-cmd --add-port=11211/tcp --zone=public --permanent

$ sudo firewall-cmd --reload

Step 4 – Configure Memcached

If you want you can configure the Memcached service from /etc/sysconfig/memcached file

$ sudo nano /etc/sysconfig/memcached

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

After making the changes, you must restart the Memcached service using

$ sudo systemctl restart memcached

Step 5 – Enable Memcached for PHP

Now let us enable Memcached for PHP by installing the required extension

$ sudo dnf install php-memcached php-memcache -y

As the installation completes, make sure to restart PHP-FPM and Memcached services

$ sudo systemctl restart php-fpm
$ sudo systemctl restart memcached

Thats all, you have Memcached installed on your server.

Category:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *