Install Memcached on Ubuntu
To install Memcached on Ubuntu, do the following steps:
- Open the terminal
- Then, type the following commands:
Verifying Memcached Installation
To verify memcached is installed or not, we need to run the following command.
When we execute the above command the output will look like this:
Here, 11211 is the default port for memcached. And 127.0.0.1 is the Host IP.
We can change the port of the memcached server by using the following command:
This command starts the server on the TCP port 11111 and listens on the UDP port 11111 as a daemon process.
Install Memcached on Windows
To install memcached on Windows, follow the following steps:
- Download a memcached from the following link:
Here, I am using the 64-bit version.
- Create a folder in any directory. Such as c:memcahed
- Extract the downloaded .zip file and copy the content of this downloaded file into the newly created directory.
- Open a command prompt as an administrator.
- Go to the c:memcahed (your newly created folder)
- Run memcached.exe file
Now, the memcached server is started.
After the memcached server is started, it listens on the port we have assigned to it. The memcached client connects to the server on either the UDP or TCP port, sends commands and receives responses, and eventually closes the connection.
We can connect to our memcached server in a variety of ways. Here we will use a Telnet client to connect to the server directly.
For this, open another command prompt and type the following command:
Here, telnet 127.0.0.1 11211 assuming the memcached server is running on the same machine and listening on the default 11211 port.
When you press enter, the following telnet client window will open:
Your memcached service should now run and wait incoming key or value pairs.
Note: When we execute the memcached.exe without any command line options, by default the memcached server will start on port 11211 with 64MB of memory.