Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering, which increases performance of dynamic web applications by alleviating database load, so in this article, I have mentioned how we can install Memcached on Windows or Linux server.
Steps to install Memcached on Windows
- Download a stable version, in either 32-bit or 64-bit I have tested the 64-bit version.
- Unzip it in some hard drive folder. For example C:\memcached
- There will be memcached.exe file in the unzipped folder.
- Open a command prompt ( as administrator, otherwise service may fail to install).
- Run below CMD command
c:\memcached\memcached.exe -d install
From the command prompt, go to the memcached directory and run the below command
memcached.exe -d install
- Start the server from the Services or by running one of the following commands:
c:/memcached/memcached.exe -d start net start memcached Server
- Once you will run above commands, memcached server is installed and is listening on port 11211.
- Memcached default memory is 64 MB, if you want to increase it, you can navigate to Registry settings (open by clicking on start, search regedit) and then navigate to
- In the key Image path, change the value to below, it will increase memory limit top 512MB
C:/memcached/memcached.exe -d runservice -m 2048
Steps to install Memcached on Linux (CentOS)
You can install Memcached from the official CentOS repositories using the following yum commands.
# yum update
# yum install memcached
Now, we will install libmemcached, which is a client library that offers a couple of tools to manage your Memcached server.
# yum install libmemcached
Memcached should now be installed on your CentOS system as a service, along with the tools that required you to test its connectivity.
Now we can proceed further to secure its configuration settings.
To make assure that the installed Memcached service is listening on the 127.0.0.1 local interface, we will alter the OPTIONS variable in the
/etc/sysconfig/memcached configuration file.
Search for option variable and update it
OPTIONS="-l 127.0.0.1 -U 0"
Once we have updated OPTIONS, we will need to restart memcached on server.
# systemctl restart memcached
# systemctl enable memcached
Now you can verify that Memcached is currently bound to the local interface and listening only for TCP connections by typing:
# sudo netstat -plunt
You will see output with memcached running on local address '127.0.0.1' with tcp protocol
You may also like to read: