Installing memcached under CentOS

Source: Internet
Author: User
Tags memcached

Installing memcached under CentOS is simple, as long as you use the CentOS-built dependency management tool, but you can also install it using a compiled method.

1. Service-side memcached

Below I will use Yum to install memcached:

[root@localhost ~]# yum install memcached


Select Y

Very simple! 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. Memcached will continue to run when exiting from the terminal window
-L: Specify the IP address, where we specify the local IP
-P: Specify port number, port number is 11211
-M: allocating memory, where I allocate 150M of memory
-u: Which user to use to run memcached

So how do we see if our memcached is up and down?
A command is described below:

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

The PS command is the abbreviation for precess status, which is the list of processes that are running on the current system
Ps-ef is the display of all processes, along with the command line
PS is typically used in combination with grep to find a specific process

2. Client Memcache

2.1 Installing 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

Attention! Here is the PHP extension, do not download memcached, after the completion of the decompression can be seen in the folder whether there are php_ such files.

2.1.3 Decompression libmemcached

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

Here is the compiled installation method:
Go to the libmemcached-1.0.8 directory and compile

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

Specify to compile into the/usr/lib/libmemcached directory

To install

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

Wait for a period of time after installation is complete!

2.2 Installing memcached extensions for PHP
2.2.1 Decompression memcached

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

Enter this folder to perform

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

It's going to be a configure file.
Perform:

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

Will error: Configure:error:Cannot find Php-config. Please Use–with-php-config=path
It means you didn't find me. Php-config this path
So we're going to specify our path, which depends on where your PHP is installed.

My php-config is under the/usr/local/php/bin.
Go to the Memcached folder to re-execute:

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

Damn, it's an error.
Configure:error:memcached support requires libmemcached. Use–with-libmemcached-dir=dir to specify the prefix where libmemcached headers and library is located
It turns out that we have not found the libmemcached extension we just installed.
Because we just./configure–prefix=/usr/bin/lib/libmemcached
So our libmemcached extension is here.
Re-execution:

[[email protected] memcached-2.2.0]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/lib/libmemcached

Nima!! Also error: Error:no, Sasl.h is not available. Run Configure WITH–DISABLE-MEMCACHED-SASL to disable this check
According to the guidelines, re-execute:

[[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

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


The following will be php.ini configuration, add memcached extension

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

Press Shift+g to jump to the last line
Insert: extension=memcached.so Save
To restart my lnmp: [[email protected] ~]# lnmp restart
To view my PHP extensions: [[email protected] ~]# php -m
To see if there are memcached extensions: [[email protected] ~]# php -m | grep memcached

Now PHP has successfully configured the memcached!

Installing memcached under CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.