Installing Memcached on Linux (CentOS 6.x):

1. yum install gcc
2. cd /tmp
3. wget http://www.monkey.org/~provos/libevent-2.0.4-alpha.tar.gz Note: Memcached uses the libevent library for Socket processing, so you need to install libevent as well.
4. tar zxvf libevent-2.0.4-alpha.tar.gz
5. cd libevent-2.0.4-alpha
6. ./configure -prefix=/usr/local/libevent
7. make
8. make install
9. cd ~
10. cd /tmp
11. http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
12. tar zxvf memcached-1.4.5.tar.gz
13. cd memcached-1.4.5
14. ./configure -prefix=/usr/local/memcached –with-libevent=/usr/local/libevent Note: You must specify the libevent installation location when installing Memcached.
15. make
16. make install
17. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libevent/lib Note: Add the libevent lib directory to LD_LIBRARY_PATH.
18. vi /etc/sysconfig/iptables
19. Add the following line:
-A RH-Firewall-l-INPUT -p tcp -m tcp –dport 11211 -j ACCEPT Note: Add Memcached to the firewall’s allowed access rules.
20. service iptables restart Note: Restart the firewall.
21. /usr/local/memcached/bin/memcached -d Note: Start Memcached.
Memcached Startup Parameter Descriptions:
-d : Start as a daemon process.
-m:Amount of memory allocated for Memcache to use, in MB. Default is 64MB.
-u :User under which Memcache runs.
-l :Server IP address to listen on.
-p :Set the port Memcache listens on. Default is 11211. Note: -p (lowercase p).
-c :Set the maximum number of concurrent connections. Default is 1024.
-P :Set the pid file path for saving Memcache’s process ID. Note: -P (uppercase P).
To stop the Memcache process, run: kill `cat pid_file_path`