Install memcached in CentOS
Installing memcached in centos is simple. You only need to use the dependency management tool that comes with centos. However, you can also use the compilation method to install memcached.
1. Server memcached
Next I will use yum to install memcached:
[root@localhost ~]# yum install memcached
Select y
Very easy! The installation is complete!
Let's start memcached!
[root@localhost ~]# /usr/bin/memcached -d -l 127.0.0.1 -p 11211 -m 150 -u root
-D: daemon. When exiting from the terminal window, memcached will continue to run-l: Specify the ip address. Here we specify the local ip address-p: Specify the port number, and the port number is 11211-m: allocate memory, here I allocated a M memory-u: which user is used to run memcached
So how can we check whether our memcached is started! The following is a command:
[root@localhost ~]# ps -ef | grep memcached
Ps command is the abbreviation of Precess Status, that is, to list the processes running in the current system ps-ef is to display all processes, together with the command line ps is usually used in combination with grep to find specific processes
2. Client memcache
2.1 install libmemcached 2.1.1 download libmemcached
[root@localhost ~]# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
2.1.2 download memcached
[root@localhost ~]# wget http://pecl.php.net/get/memcached-2.2.0.tgz
Note! The php extension is downloaded here. Do not download memcached. After decompression, check whether there are php _ files in the folder.
2.1.3 decompress libmemcached
[root@localhost ~]# tar -zxvf libmemcached-1.0.8.tar.gz
Here is the use of the compilation and Installation Method: Enter the libmemcached-1.0.8 directory, compile
[root@localhost ~]# ./configure --prefix=/usr/lib/libmemcached
Specify to compile to the/usr/lib/libmemcached directory
Install
[root@localhost libmemcached-1.0.8]# make && make install
Wait for a while and the installation is complete!
2.2 install memcached extension for PHP 2.2.1 decompress memcached
[root@localhost ~]# tar -zxvf memcached-2.2.0.tar.gz
Enter this folder and run
[root@localhost ~]# cd memcached-2.2.0[root@localhost memcached-2.2.0]# phpize
At this time, an extra configure file will be executed:
[root@localhost memcached-2.2.0]# ./configure
The following error occurs: configure: error: Cannot find php-config. please use-with-php-config = PATH indicates that the PATH "My php-config" is not found. Therefore, we need to specify our PATH. here we need to determine where your php is installed.
My php-config is re-executed in the memcached folder under/usr/local/php/bin:
[root@localhost memcached-2.2.0]# ./configure --with-php-config=/usr/local/php/bin/php-config
Fuck, and an error is reported again. Configure: error: memcached support requires libmemcached. use-with-libmemcached-dir = DIR to specify the prefix where libmemcached headers and library are located. We didn't find the libmemcached extension we just installed. Because we just had./configure-prefix =/usr/bin/lib/libmemcached, our libmemcached extension is here. Run the following command:
[root@localhost memcached-2.2.0]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/lib/libmemcached
Nima !! Another error is reported: error: no, sasl. h is not available. Run configure with-disable-memcached-sasl to disable this check. Follow the instructions and then execute:
[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 succeeded!2.2.2 installation Extension
[root@localhost memcached-2.2.0]# make && make install
The following describes how to configure php. ini and add the memcached extension.
[root@localhost ~]# vim /usr/local/php/etc/php.ini
Press shift + g to jump to the last line and insert: extension = memcached. so save and restart my lnmp:[root@localhost ~]# lnmp restart
Check out my php extensions:[root@localhost ~]# php -m
Check whether memcached extensions are available:[root@localhost ~]# php -m | grep memcached
Now php has successfully configured memcached!