Memcached is an open-source and high-performance in-memory caching system. Generally, it is used to speed up web applications by caching session data, user authentication tokens, and API calls. Its aim is to accelerate dynamic web applications by alleviating database load. Memcached reduces application load by storing data objects in dynamic memory.
In this tutorial, we will explain how to install Memcached on CentOS 8.
A fresh CentOS 8 VPS on the Atlantic.net Cloud Platform
A root password configured on your server
Step 1 – Create Atlantic.Net Cloud Server
First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing CentOS 8 as the operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.
Once you are logged in to your CentOS 8 server, run the following command to update your base system with the latest available packages.
dnf update -y
Step 2 – Install Memcached
By default, Memcached is available in the CentOS 8 default repository. You can install it by just running the following command:
dnf install memcached libmemcached -y
After installing Memcached, start the Memcached service and enable it to start at boot with the following command:
You can also verify the status of the Memcached service with the following command:
systemctl status memcached
You should see the following output:
memcached.service - memcached daemon
Loaded: loaded (/usr/lib/systemd/system/memcached.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2020-08-07 06:30:57 EDT; 10s ago
Main PID: 9933 (Memcached)
Tasks: 10 (limit: 12537)
└─9933 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -l 127.0.0.1,::1
Aug 07 06:30:57 centos8 systemd: Started memcached daemon.
Step 3 – Configure Memcached
Memcached default configuration file is located at /etc/sysconfig/memcached. By default, Memcached is configured to listen on the localhost. If your application is hosted on the same server, then you don’t need to configure Memcached. If your application is hosted on the remote server, then you will need to configure Memcached to listen on that IP address and allow access to the Memcached port 11211 only from the client IP address.
To see the Memcached default configuration, run the following command:
Next, start the Nginx server and enable it to start at boot with the following command:
systemctl start nginx systemctl enable nginx
Now, open your web browser and type the URL http://your-server-ip/info.php. You should see the Memcached section in the following screen:
Congratulations! You have successfully installed and configured Memcached on CentOS 8. You can now integrate your web application with Memcached and use its features to speed up your website on VPS hosting from Atlantic.Net. For more information, visit the Memcached documentation.