Extension of memcached installation in php based on libmemcached

Source: Internet
Author: User
The libmemcached-based extension memcached service for php is based on libmemcached. the installation of php extension memcached is published on? In the original article blog.51yip.comphp928.html 1, why is the memcached extension 1.2.4 and later added CAS (CheckandSe extended memcached service for php based on libmemcached

Extension of memcached installation in php based on libmemcached

Zhang Ying posted on? Original http://blog.51yip.com/php/928.html

I. Why do I need to install the memcached extension?

The CAS (Check and Set) protocol is added to the 1.2.4 and later versions of memcached to solve the concurrent processing problem of the multi-entry route of the same key. In fact, the root database is very similar. if there are several processes updating the same data in the same table at the same time, will there be a fight? haha. The entire table can be locked in the database, or the row in the table can be locked. In fact, the CAS root added to memcached is similar.

Php extension memcache does not support cas, so we need to install the memcached extension. The memcached extension is based on libmemcached, so we need to install libmemcached first.

?

2. view the version of memcahced.

Telnet fig 12000
Stats
You will see the following information
STAT pid 15322
Statuptime 1885
STAT time 1279455772
STAT version 1.2.8
STAT pointer_size 32
If the version is too low, reinstall it.

Exit telnet,Ctrl +] then Press q.

3. install the required software

Wget http://launchpad.net/libmemcached/1.0/0.42/+download/libmemcached-0.42.tar.gz

Wget http://pecl.php.net/get/memcached-1.0.2.tgz

Memcached official website http://www.memcached.org/

4. install libmemcached

Tar zxvf libmemcached-0.42.tar.gz
Cd libmemcached-0.42
./Configure -- prefix =/usr/local/libmemcached? -- With-memcached
Make & make install

Notes for installation:

1 ,? Do not forget to install it. -- with-memcached; otherwise, you will be prompted.

Checking for memcached... no
Configure: error: "cocould not find memcached binary"

2. is your memcached above 1.2.4? If not, you will be prompted

Clients/ms_thread.o: In function 'Ms _ setup_thread ':
/Home/zhangy/libmemcached-0.42/clients/ms_thread.c: 225: undefined reference to '_ sync_fetch_and_add_4'
Clients/ms_thread.o:/home/zhangy/libmemcached-0.42/clients/ms_thread.c: 196: more undefined references to '_ sync_fetch_and_add_4' follow
Collect2: ld returned 1 exit status
Make [2]: *** [clients/memslap] Error 1
Make [2]: Leaving directory '/home/zhangy/libmemcached-0.42'

Solution is -- disable-64bit CFLAGS = "-O3-march = i686", if you don't need this 64-bit long data, I want php to expand memcached, memcache will be no difference, it doesn't make much sense to install memcached.

5. php extension memcached installation

Tar zxvf memcached-1.0.2.tar.gz
Cd memcached-1.0.2
/Usr/local/php/bin/phpize
./Configure -- enable-memcached -- with-php-config =/usr/local/php/bin/php-config -- with-libmemcached-dir =/usr/local/libmemcached
./Configure -- prefix =/usr/local/phpmemcached? -- With-memcached
Make & make install

Vi/usr/local/php/lib/php. ini

Add extension = memcached. so and restart the service.

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.