Installation of CentOS system memcached and PHP extended configuration

Source: Internet
Author: User
Tags memcached php memcached centos

I. Installation of libevent development kits

The code is as follows Copy Code
Yum Install Libevent-devel

Second, install memcached
We get memcached installation package memcached-1.4.15.tar.gz from http://memcached.org/.

1. Configuration (Specify installation directory via parameter prefix)

The code is as follows Copy Code
./configure--prefix=/usr/local/memcached--ENABLE-SASL

2. Compiling and installing

The code is as follows Copy Code
Make
Make install

Iii. installation of libmemcached
Download the installation package libmemcached-1.0.15.tar.gz from the http://libmemcached.org/.

Configuration, compilation, and installation (–with-memcached specifies memcached execution program)

The code is as follows Copy Code

./configure--with-memcached=/usr/local/memcached/bin/memcached
Make
Make install

Iv. Installing PHP memcached Extensions

The code is as follows Copy Code

/usr/local/php/bin/pecl Install memcached

If you encounter this error:

Error while loading shared Libraries:libevent-1.4.so.2:cannot open Shared object file:no such file or directory

Indicates that although the Libevent 2.0 library is installed, it cannot be found in the system library because it was not added to the system library after installation and only exists in the user library:

Make a soft connection ln-s/usr/local/libevent/lib/libevent-1.4.so.2
/usr/lib/libevent-1.4.so.2 5. (or copy libevent-1.4.so.2 to/usr/lib/, or you can
Startup parameters:

-D Sets the memory size that the memcached can use in a daemon (daemon) mode, with the M-m setting memcached does not lru-l set the IP address of the listener, and if this is the case, this parameter can usually not be set;-P Set the listening port, the default is 11211, so you can also not set this parameter;-u specifies the user, if the current is root, you need to use this parameter to specify the user. -P Records memcache run PID to file/usr/local/bin/memcached.pid-n set the initial chunk size-f chunk size factor growth factor, default is 1.25

for boot startup , memcached is not registered as a system service, so the startup mode is slightly different:

The code is as follows Copy Code

# echo "/usr/local/bin/memcached-d-M 10-u root-l 192.168.5.47-p 12000-p/tmp/memcached.pid" >>/etc/rc.d/rc.loc Al

Test memcached:

The code is as follows Copy Code

[root@localhost/]# telnet 192.168.141.64 12000
Trying 192.168.141.64 ...
Connected to 192.168.141.64 (192.168.141.64).
Escape character is ' ^] '.
Set Key1 0 60 4
Zhou
STORED
Get Key1
VALUE Key1 0 4
Zhou
End

This memcached installation is successful!

Create a Memcached object

  code is as follows copy code

<?php
/* Create a Normal object */
$m 1 = new Memcached ();
Echo Get_class ($m);

/* Create persistent Object */
$m 2 = new Memcached (' Story_pool ');
$m 3 = new Memcached (' Story_pool ');

/* Now $M2 and $M3 share the same connection */

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.