Home > Article > Backend Development > Compile and install memcached service under linux, linuxmemcached_PHP tutorial
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`
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.
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