This approach is recommended when you deploy a production environment
Memcached relies on libevent, so the installation libevent must be compiled first. Both need to be installed in the Gnu/linux system with more than 2.6 kernel versions. Before compiling, verify that the GCC, make, Patch, and other compilation tools are installed and ready for use.
(1) Compiling source code
Get Libevent
Download the latest version from Libevent's official site (http://www.monkey.org/~provos/libevent/) or use the libevent-2.0.10-stable.tar.gz on the file server
Compiling, installing libevent
#tar-ZXVF libevent-x.x.x-stable.tar.gz
#cd libevent-x.x.x-stable
#./configure && make && make install &&
Get memcached
#wget Http://memcached.org/latest
Or use memcached-1.4.5.tar.gz on the file server
Compiling, installing memcached
#tar-ZXVF memcached-1.x.x.tar.gz
#cd memcached-1.x.x
#./configure--prefix=/usr/local/memcached--with-libevent=/usr/local
#make
#make Install
(2) Start memcached server
#cd/usr/local/memcached/bin
#./memcached-d-M 50-p 11211-u Root
Parameter Description:-m Specifies how many megabytes of cache space to use;-p specifies the port to listen on;-u specifies which user to run
Parameter explanation:
-D runs memcached in the daemon (daemon) mode;
-M sets the amount of memory that memcached can use, in units of M;
-L Set the listening IP address, if it is native, it is usually possible not to set this parameter;
-P Sets the listening port, which defaults to 11211, so you can also not set this parameter;
-u specifies that the user should be specified using this parameter if it is currently root.
(3) Troubleshooting
After the installation is complete, you may receive the following error when you start memcached:
./memcached:error while loading shared libraries:libevent-2.0.so.5:cannot open Shared object file:no such file or dire Ctory
The system cannot locate the Libevent library, and you can solve the problem in this way:
Ln-s/usr/local/lib/libevent-2.0.so.5.0.1/lib/libevent-2.0.so.5
If it is a 64-bit operating system, point to the/lib64 directory
Ln-s/usr/local/lib/libevent-2.0.so.5.0.1/lib64/libevent-2.0.so.5
Linux Memcache Build