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 you exit from the terminal window, memcached continues to run.
-L: Specifies the ip address. Here we specify the local ip address.
-P: Specifies the port number. The port number is 11211.
-M: memory allocation. I allocated MB of memory here.
-U: the user 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
The ps command is short for Precess Status, that is, to list the processes running in the current system.
Ps-ef displays 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 compilation and installation method used:
Go to the libmemcached-1.0.8 directory to 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, a configure file will be added.
Run:
[root@localhost memcached-2.2.0]# ./configure
The following error occurs: configure: error: Cannot find php-config. Please use-with-php-config = PATH.
This indicates that the path of my php-config is not found.
So we need to specify our path. It depends on where your php is installed.
My php-config is under/usr/local/php/bin.
Go to the memcached folder and run the following command again:
[root@localhost memcached-2.2.0]# ./configure --with-php-config=/usr/local/php/bin/php-config
An error is reported.
Configure: error: memcached support requires libmemcached. Use-with-libmemcached-dir = DIR to specify the prefix where libmemcached headers and library are located
The libmemcached extension we just installed was not found.
Because we have just./configure-prefix =/usr/bin/lib/libmemcached
So 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
Error: no, sasl. h is not available. Run configure with-disable-memcached-sasl to disable this check
Perform the following operations according to the guidelines:
[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
Shift + g to the last line
Insert: extension = memcached. so save
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!
Install and configure Memcached source code in CentOS 6.6
Memcached installation and startup script
Performance problems of using Memcached in PHP
Install Memcached in Ubuntu and its command explanation
Install and apply Memcached
Use Nginx + Memcached's small image storage solution
Getting started with Memcached
For details about Memcached, click here
Memcached: click here
This article permanently updates the link address: