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:
[[email protected] ~]# yum install memcached
Very simple! Installation complete!
Let us start memcached it!
[[email protected] ~]# /usr/bin/memcached -d -l 127.0.0.1 -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:
[[email protected] ~]# 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
[[email protected] ~]# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
2.1.2 download memcached
[[email protected] ~]# wget http://pecl.php.net/get/memcached-2.2.0.tgz
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
[[email protected] ~]# tar -zxvf libmemcached-1.0.8.tar.gz
Here is the compile and install method: into the libmemcached-1.0.8 directory and compile
[[email protected] ~]# ./configure –prefix=/usr/lib/libmemcached
Specify compile to/usr/lib/libmemcached directory
[[email protected] 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
[[email protected] ~]# tar -zxvf memcached-2.2.0.tar.gz
Access to this folder, do
At this point would have a configure file:
[[email protected] 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:
[[email protected] 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:
[[email protected] 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:
[[email protected] 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
[[email protected] memcached-2.2.0]# make && make install
Following to PHP.ini configuration, add memcached extension
[[email protected] ~]# vim /usr/local/php/etc/php.ini
Press shift+g to jump to the last row inserted: extension=memcached.so save restart my lnmp:[[email protected] ~]# lnmp restart check my PHP extensions:[[email protected] ~]# php -m see if memcached extension:[[email protected] ~]# php -m | grep memcached