Install php memcached client under linux, linuxmemcached_PHP tutorial

WBOY
Release: 2016-07-13 10:21:32
Original
919 people have browsed it

Install php memcached client under linux, linuxmemcached

The following will introduce the installation steps of memcached client for installing php

1. Download and install libmemcached client
Official website address: http://libmemcached.org/libMemcached.html

$wget -c https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
#亲 千万不要下载1.0.17哦 有bug
$tar -zxvf libmemcached-1.0.16.tar.gz
$cd libmemcached-1.0.16
$./configure --prefix=/usr/local/libmemcached --with-memcached
$sudo make
$sudo make install
Copy after login

2. Download and install memcached
Official website address: http://pecl.php.net/package/memcached

$wget -c http://pecl.php.net/get/memcached-2.2.0b1.tgz
$tar -zxvf memcached-2.2.0b1.tgz
$cd memcached-2.2.0b1
$sudo /usr/local/php/bin/phpize
$./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disabled-memcached-sasl
$sudo make
$sudo make install
Copy after login

3. Restart php nginx

$sudo /etc/init.d/nginx restart
$sudo /etc/init.d/php restart
Copy after login

Note: How to write scripts to restart nginx and php. Reference
php startup script
nginx startup script

4. Check whether the installation is successful
If the phpinfo() function appears as follows, the installation is successful

linux Install PHP’s memcached extension

First make sure there is a difference between memcache and memcached.
Telnet successfully proves that memcache is successfully installed.
phpinfo shows memcached, so that’s no problem

But you said
using the official PHP file to test memcached is useless, the page prompts a 500 error
I wonder if you are using something similar to this code.
$mem = new Memcache;
$mem->connect("192.168.x.y", 11211)or die ("Could not connect");

$mem->set('key', 'This is a test!', 0, 60);
$val = $mem->get('key');
echo $val;
?>

Pay attention to the first line. . $mem = new Memcache;

If your server supports memcached, memcached will be displayed in phpinfo
If it is memcache, only memcache will be displayed

memcached is php an extension of.
So if you use new memcache to instance memcached, it is normal that 500 will appear.

What is the relationship between Linux memcached and php’s memcache extension

Linux’s memcached is the server side
php’s memcache is the client side
The client accesses the server side to access data

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/856990.htmlTechArticleInstall the memcached client of php under linux, linuxmemcached The following will introduce the installation steps of memcached client of php 1. Download Install the libmemcached client official website address: http://libmem...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!