Home  >  Article  >  Backend Development  >  Compile and install memcached service under linux, linuxmemcached_PHP tutorial

Compile and install memcached service under linux, linuxmemcached_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:21:29844browse

Compile and install the memcached service under linux, linuxmemcached

System: Ubuntu 13.10
Step 1: Install libevent-dev

$aptitude search libevent-dev
$aptitude install libevent-dev

Step 2: Download memcached and install it
Official website address: http://memcached.org/

$wget -c http://www.memcached.org/files/memcached-1.4.17.tar.gz
$tar -zxvf memcached-1.4.17.tar.gz
$cd memcached-1.4.17
$./configure --prefix=/usr/local/memcached
$ make
$ sudo make install

Step 3: Start memcached

$cd /usr/local/memcached
$./memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -P /tmp/memcached.pid

Step 3: Check whether the installation is successful

$ps -aux | grep memcache #法1
$netstat -antu | grep 11211 #法2
$telnet localhost 11211 #法3

Common commands
Start memcached service

#./memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -P /tmp/memcached.pid

Close memcached service

#kill `cat /tmp/memcached.pid`

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.
ec6e2c48ebaf9044f8f0836b80e7f002connect("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.

The memcached I installed in linux before is easy to use in java programs. Now I installed memcached on windows and the process already has memcached

First use telnet to connect to the open listening port of memcached on the computer where Windows is located to see if the connection can be made

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/856993.htmlTechArticleCompile and install the memcached service under linux, linuxmemcached system: Ubuntu 13.10 Step 1: Install libevent-dev $aptitude search libevent -dev$aptitude install libevent-dev Step 2: Download...
Statement:
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