how to install memcached on centos 6 – 7

In the CentOS install memcached is simple, just use CentOS since dependency management tool can, but you can use the compile method to install it.
1. Server memcached

I am going to use yum to install memcached:

[root@localhost ~]# yum install memcached

Select y

Very simple! Installation complete!

Let us start memcached it!

[root@localhost ~]# /usr/bin/memcached -d -l -p 11211 -m 150 -u root

-D: daemon. When exit from the Terminal window, memcached will continue to run-l: specify the IP address, here we specify local: specify the port number and port number as follows: allocated memory I allocate 150M memory-u: which user to use memcached

How so view our memcached started it! Here’s a command:

[root@localhost ~]# ps -ef | grep memcached

PS command is short for Precess Status, which lists all the processes currently running processes in the system are displayed, along with the command line PS is usually used in combination with grep, find specific processes
2. client Memcache

2.1 Installing the libmemcached 2.1.1 download libmemcached

[root@localhost ~]# wget

2.1.2 download memcached

[root@localhost ~]# wget

Attention! Here to download the PHP extension, do not download the memcached, can look after it unzipped folder in the php_ files.

2.1.3 extract libmemcached

[root@localhost ~]# tar -zxvf libmemcached-1.0.8.tar.gz

Here is the compile and install method: into the libmemcached-1.0.8 directory and compile

[root@localhost ~]# ./configure –prefix=/usr/lib/libmemcached

Specify compile to/usr/lib/libmemcached directory


[root@localhost libmemcached-1.0.8]# make && make install

Waits for a period of time after the installation is complete!

2.2 to install memcached PHP extension 2.2.1 extract memcached

[root@localhost ~]# tar -zxvf memcached-2.2.0.tar.gz

Access to this folder, do

[root@localhost ~]# cd memcached-2.2.0
[root@localhost memcached-2.2.0]# phpize

At this point would have a configure file:

[root@localhost memcached-2.2.0]# ./configure

Error: configure:error:Cannot find php-config. Please use – with-php-config=PATH I php-config the path is not found so we need to specify the path here depending on your PHP installation to which to determine

My php-config under/usr/local/PHP/bin into memcached folder again:

[root@localhost memcached-2.2.0]# ./configure –with-php-config=/usr/local/php/bin/php-config

Fuck, and correct. configure: error: memcached support requires libmemcached. Use – with-libmemcached-dir=DIR to specify the prefix where libmemcached headers and library are located is not found we just installed libmemcached extensions. Because we just./configure – prefix=/usr/bin/lib/libmemcached libmemcached extensions so we are here. Then do:

[root@localhost memcached-2.2.0]# ./configure –with-php-config=/usr/local/php/bin/php-config –with-libmemcached-dir=/usr/lib/libmemcached

Nima!! Error: error:no, SASL.h is not available. Run configure with – disable-memcached-SASL to disable this check according to the guidelines, then do:

[root@localhost memcached-2.2.0]# ./configure –with-php-config=/usr/local/php/bin/php-config –with-libmemcached-dir=/usr/lib/libmemcached –disable-memcached-sasl

Finally success! 2.2.2 Installing extensions

[root@localhost memcached-2.2.0]# make && make install

Following to PHP.ini configuration, add memcached extension

[root@localhost ~]# vim /usr/local/php/etc/php.ini

Press shift+g to jump to the last row inserted: save restart my lnmp:[root@localhost ~]# lnmp restart check my PHP extensions:[root@localhost ~]# php -m see if memcached extension:[root@localhost ~]# php -m | grep memcached