How To Install Memcached on Fedora 38
In this tutorial, we will show you how to install Memcached on Fedora 38. For those of you who didn’t know, Memcached, a high-performance, distributed memory object caching system, has gained immense popularity in the realm of web application development. Its primary role is to speed up data retrieval by caching frequently accessed data in memory, thereby reducing the load on your database server. One of the most flexible and powerful ways to install Memcached is from the source code, enabling you to tailor the installation to your exact requirements.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Memcached on a Fedora 38.
Prerequisites
- A server running one of the following operating systems: Fedora 38.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Memcached.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Memcached on Fedora 38
Step 1. Before we can install Memcached on Fedora 38, it’s important to ensure that our system is up-to-date with the latest packages. This will ensure that we have access to the latest features and bug fixes and that we can install Memcached without any issues:
sudo dnf update
Step 2. Installing Essential Development Tools.
To compile Memcached from source, you’ll need essential development tools. Open your terminal and install them with the following command:
sudo dnf groupinstall 'Development Tools' sudo dnf install libevent libevent-devel
After installing the dependencies, verify that they are correctly installed and accessible. You can use the pkg-config
command to check the library’s availability. For example:
pkg-config --list-all | grep libevent
Step 3. Installing Memcached on Fedora 38.
Download the latest version of Memcached from the official website using the following command:
https://www.memcached.org/files/memcached-1.6.21.tar.gz
Once the source code is downloaded, extract it using the following command:
tar xvzf memcached-1.6.21.tar.gz
Navigate to the newly created directory:
memcached-1.6.21
To configure Memcached, run the configure
script. This script will check your system for dependencies and set up the build environment. Execute it with:
./configure
If you need to customize Memcached’s configuration, you can specify various options when running the configure
script. For instance, if you want to change the installation directory, use:
./configure --prefix=/path/to/installation/directory
After configuring, run the make
command to generate the Makefile:
make
With the source code compiled, it’s time to install Memcached on your system:
sudo make install
Verify that the installation was successful by checking the Memcached version:
memcached -h
Step 4. Starting Memcached Service.
Starting the Memcached service is a straightforward process. In your terminal, run:
memcached -d -u <your_username> -m 64 -p 11211
-d
: This flag runs Memcached as a daemon.-u
: Specify the username under which Memcached will run.-m
: Set the maximum amount of memory that Memcached can use (in megabytes).-p
: Define the port Memcached will listen on (default is 11211).
Ensure that you replace <your_username>
with your actual username. Memcached is now up and running.
Step 5. Memcached Configuration.
Memcached uses a configuration file to specify its settings. The default configuration file is /etc/memcached.conf
. You can edit this file to change the configuration options.
- Memory Allocation
The -m
option is used to specify the amount of memory that Memcached can use. The default value is 64MB. You can increase or decrease this value depending on the amount of memory available on your system.
- Listening Port
The -p
option is used to specify the port on which Memcached listens for incoming connections. The default value is 11211. You can change this value if you want to use a different port.
- User and Group
The -u
option is used to specify the user under which Memcached should run. The default value is nobody
. You can change this value if you want to run Memcached under a different user. The -l
option is used to specify the IP address on which Memcached should listen for incoming connections. The default value is 127.0.0.1
, which means that Memcached only accepts connections from the local machine. You can change this value if you want to accept connections from other machines.
- Verbosity
The -v
option is used to specify the verbosity level of Memcached. The default value is 0, which means that Memcached runs in quiet mode. You can increase this value to get more verbose output.
- Connection Limit
The -c
option is used to specify the maximum number of connections that Memcached can handle simultaneously. The default value is 1024. You can increase or decrease this value depending on the expected load on your system.
- Item Size Limit
The -I
option is used to specify the maximum size of an item that can be stored in Memcached. The default value is 1MB. You can increase or decrease this value depending on the size of the data that you want to store in Memcached.
- Slab Allocation
Memcached uses a slab allocator to allocate memory for items. The -n
option is used to specify the number of slabs that Memcached should use. The default value is calculated based on the amount of memory allocated to Memcached. You can increase or decrease this value depending on the expected load on your system.
Congratulations! You have successfully installed Memcached. Thanks for using this tutorial for installing the Memcached on your Fedora 38 system. For additional help or useful information, we recommend you check the official Memcached website.