libevent-1.4.13-stable .tar.gz

1. libevnet安装

tar zxvf libevent-1.4.13-stable .tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local/libevent
sudo make install

2. memcached安装

tar zxvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
sudo make install

3. 启动memcached

cd /usr/local/memcached/bin
./memcached -d -m 10 -u root -l -p 11211-c 250 -P /tmp/


netstat -nl | grep 11211
tcp        0      0 *               LISTEN     
tcp6       0      0 :::11211                :::*                    LISTEN     
udp        0      0 *                          
udp6       0      0 :::11211                :::*


sudo apt-get install php5-memcache

6. php连接测试

< ?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br />\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br />\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br />\n";


Server's version: 1.4.4
Store data in the cache (data will expire in 10 seconds)
Data from the cache:
object(stdClass)#3 (2) {
  string(4) "test"

7. 将memcached的启动和关闭命令写到脚本中

echo "Memcached startup...";
./memcached -d -m $MEM_SIZE -u root -p $PORT -c $CONCURRENT -P $PID_FILE
if [ $? = "0" ]; then
echo "Success...";
echo "Failure...";

ps aux | grep 'memcached' | grep -v 'grep' | awk '{print $2}' | xargs kill


机器人 2009年12月9日 16:25 于 北京 阴

此条目发表在 linux/server 分类目录,贴了 , 标签。将固定链接加入收藏夹。

Memcached安装》有 14 条评论

  1. virteman 说:

    其实可以用 killall memcached 完成相应的任务。

    • 机器人 说:

      解决问题的办法不是唯一的,你完全还可以说取个pid有这么麻烦吗?还用awk,完全可以用`cat /tmp/` 来取得pid,然后直接用 kill `cat /tmp/`就可以搞定!这分明是要练习awk嘛!哈哈!!

  2. mypad media 说:

    Thanks for the sensible critique. Me and my neighbor were just preparing to do some research on this. We got a grab a book from our local library but I think I learned more clear from this post. I’m very glad to see such excellent info being shared freely out there.

  3. What’s Taking place i am new to this, I stumbled upon this I have discovered It absolutely useful and it has helped me out loads. I hope to give a contribution & aid different customers like its helped me. Good job.

  4. Pingback 引用通告:

  5. Pingback 引用通告: sell used iphone 3g

  6. Pingback 引用通告: best place to sell iphone

  7. Good answers in return of this question with real arguments and
    describing the whole thing regarding that.

  8. uefa cup final 说:

    I finf the Last story wonderful, just like a fantasy Games , but its as good as the Brave from Pixar , can’t wait to get hold on it

  9. King Pilarz 说:

    I discovered your weblog web site on google and check just a few of your early posts. Continue to maintain up the very good operate. I just further up your RSS feed to my MSN News Reader. Searching for forward to reading extra from you later on!…

  10. hey there and thank you for your info – I’ve certainly picked up something new from right here. I did however expertise a few technical points using this web site, since I experienced to reload the web site a lot of times previous to I could get it to load properly. I had been wondering if your web hosting is OK? Not that I’m complaining, but sluggish loading instances times will very frequently affect your placement in google and could damage your high-quality score if advertising and marketing with Adwords. Well I am adding this RSS to my email and can look out for much more of your respective interesting content. Ensure that you update this again very soon..

  11. Rina Lemcke 说:

    Thank you for your entire work on this web page. Kim takes pleasure in setting aside time for investigation and it is obvious why. Most people learn all regarding the powerful means you create simple things through this blog and in addition encourage contribution from some other people on that theme and our favorite simple princess has always been understanding a lot of things. Enjoy the remaining portion of the year. You’re performing a really great job.

  12. Mose 说:

    They can also include a Carbon Monoxide Detector
    which detects the carbon monoxide is a very dangerous gas.
    Alarms with panic buttons are also available so that you can press them and inform the main centre of any intruder.
    Along with a fence, you can strategically place trees and bushes to further deter criminals.


电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>