Install memcache extension in CentOS PHP

Source: Internet
Author: User
Tags zts

Install memcache extension in CentOS PHP

1. Install the libmemcached Library

Yum install libmemcached

2. Download and decompress the memcache File

Wget http://pecl.php.net/get/memcache-3.0.8.tgz

Tar xzvf memcache-3.0.8.tgz

Cd memcache-3.0.8

3. Run the phpize extension Installer. Assume that the phpzie path is/usr/local/php/bin/phpize. The specific path must be modified according to your environment.

[Root @ nagw.memcache-3.0.8] #/usr/local/php/bin/phpize

Processing ing:

PHP Api Version: 20100412

Zend Module Api No: 20100525

Zend Extension Api No: 220100525

4. start installing extended memcache

[Root @ nag1_memcache-3.0.8] #./configure -- enable-memcache \

-- With-php-config =/usr/local/php/bin/php-config -- with-zlib-dir \

Make & make install

Prompt after installation is complete

Build complete.

Don't forget to run 'make test '.

Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/

5. Modify the php. ini file and add the following code before zend.

Vim/usr/local/php/lib/php. ini

Extension =/usr/local/php/lib/php/extension/ no-debug-non-zts-20100525/memcache. so

6. Restart php-fpm.

Kill-QUIT pid

/Usr/local/php/sbin/php-fpm

7. You can view memcached information through phpinfo ().

8. Start memecached.

./Memcached-d-m 100-l 192.168.1.120-p 11211-u root

9. Test

With the php memcache test code:

<? Php

$ Mem = new Memcache;

$ Mem-> connect ("192.168.1.120", 11211) or die ("cocould not connect ");

$ Version = $ mem-> getVersion ();

Echo "Server's version:". $ version. "<br/> \ n ";

$ Mem-> set ('hellokey', 'Hello world', 0,600) or die ("Failed to save data at the memcached server ");

Echo "Store data in the cache (data will expire in 600 seconds) <br/> \ n ";

$ Get_result = $ mem-> get ('hellokey ');

Echo "$ get_result is from memcached server .";

?>

View hit results

Telnet 192.168.1.12011211

Enter the command: status

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.