Memcached Install
# Linux Memcached Installation
Memcached supports many platforms: Linux, FreeBSD, Solaris, Mac OS, and can also be installed on Windows.
To install Memcached on a Linux system, you first need to install the libevent library.
sudo apt-get install libevent libevent-dev (Automatic download and installation for Ubuntu/Debian)
yum install libevent libevent-devel (Automatic download and installation for Redhat/Fedora/Centos)
* * *
## Installing Memcached
### Automatic Installation
**Ubuntu/Debian**
sudo apt-get install memcached
**Redhat/Fedora/Centos**
yum install memcached
**FreeBSD**
portmaster databases/memcached
After installation, you can use `whereis` to check the command path:
whereis memcached
The installation location is found to be **/usr/bin/memcached**.
### Source Code Installation
Download the latest version of Memcached from its official website (http://memcached.org).
wget http://memcached.org/latest (Download the latest version)
tar -zxvf memcached-1.x.x.tar.gz (Extract the source code)
cd memcached-1.x.x (Enter the directory)
./configure --prefix=/usr/local/memcached (Configure)
make && make test (Compile)
sudo make install (Install)
* * *
## Running Memcached
Running the Memcached command:
$ /usr/local/memcached/bin/memcached -h (Command help)
Note: If installed automatically, the memcached command is located at **/usr/local/bin/memcached**.
**Startup Options:**
* `-d` is to start a daemon process;
* `-m` is the amount of memory allocated for Memcache, in MB;
* `-u` is the user to run Memcache as;
* `-l` is the IP address of the server to listen on, multiple addresses are allowed;
* `-p` is the port for Memcache to listen on, preferably above 1024;
* `-c` is the maximum number of concurrent connections, default is 1024;
* `-P` is to set the pid file for saving Memcache's process ID.
### (1) Running as a foreground program:
Enter the following command in the terminal to start memcached:
/usr/local/memcached/bin/memcached -p 11211 -m 64m -vv
slab class 1: chunk size 88 perslab 11915
slab class 2: chunk size 112 perslab 9362
slab class 3: chunk size 144 perslab 7281
... (omitted)
slab class 38: chunk size 391224 perslab 2
slab class 39: chunk size 489032 perslab 2
<23 server listening
<24 send buffer was 110592, now 268435456
<24 server listening (udp)
<24 server listening (udp)
<24 server listening (udp)
<24 server listening (udp)
This displays debug information. This starts memcached in the foreground, listening on TCP port 11211, with a maximum memory usage of 64M. Most of the debug information is about storage.
### (2) Running as a background service:
# /usr/local/memcached/bin/memcached -p 11211 -m 64m -d
Or
/usr/local/memcached/bin/memcached -d -m 64M -u root -l 192.168.0.200 -p 11211 -c 256 -P /tmp/memcached.pid
AI is thinking...
[](#)(#)
(#)[](#)
YouTip