{"id":476,"date":"2013-07-03T13:58:37","date_gmt":"2013-07-03T05:58:37","guid":{"rendered":"http:\/\/www.ln.la\/?p=476"},"modified":"2013-07-03T13:58:37","modified_gmt":"2013-07-03T05:58:37","slug":"memcache-problems","status":"publish","type":"post","link":"https:\/\/www.lnlog.cn\/index.php\/2013\/07\/03\/memcache-problems\/","title":{"rendered":"PHP5.4.x\u548cMemcache\u7684\u7248\u672c\u4e0d\u517c\u5bb9\u95ee\u9898"},"content":{"rendered":"<p>\u4e0b\u8f7d\u76ee\u524d\u6700\u65b0\u7684PHP5.4.8\u7f16\u8bd1\u540e(fpm)\uff0c\u4f7f\u7528sudo apt-get install memcached\u5b89\u88c5memcache\u670d\u52a1\uff0c\u518d\u4f7f\u7528Pecl:<a href=\"http:\/\/www.ln.la\/473\/pecl-pear-php-extensions.html\">http:\/\/www.ln.la\/473\/pecl-pear-php-extensions.html<\/a>\u5b89\u88c5memcache\uff08sudo pecl install memcache\uff09PHP\u6269\u5c55\uff0c\u7f16\u8bd1\u540ememcache.so\u5728\/usr\/lib\/php5\/20090626\/\u4e2d\uff0c\u5728PHP.ini\u6dfb\u52a0\u597dextension\uff0c\u91cd\u542fphpfpm\uff08\u4e0d\u662f\u91cd\u542fnginx\uff09\uff0c\u51fa\u73b0\u4e0b\u9762\u7684\u9519\u8bef\u4fe1\u606f\uff1a<\/p>\n<p>1 Gracefully shutting down php-fpm . done<\/p>\n<p>2 Starting php-fpm [25-Oct-2012 12:04:02] NOTICE:<\/p>\n<p>3 PHP message: PHP Warning: PHP Startup: memcache: Unable to initialize module<\/p>\n<p>4 Module compiled with module API=20090626<\/p>\n<p>5 PHP compiled with module API=20100525<\/p>\n<p>6 These options need to match<\/p>\n<p><!--more--><\/p>\n<p>\u7f16\u8bd1PHP\u4f7f\u7528\u7684PHP\u6838\u5fc3\u7248\u672c\u662f20100525\uff0c\u800cPecl\u91cc\u9762\u7684Memcache\u662f\u4f7f\u752820090626\u7248\u672c\u7f16\u8bd1\u7684\uff0c\u7248\u672c\u4e0d\u4e00\u81f4\u5bfc\u81f4PHP\u65e0\u6cd5\u542f\u7528memcache.so\u5e93\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u5378\u8f7d\u6389Pecl\u65b9\u5f0f\u5b89\u88c5\u7684Memcache\uff0c\u53bb<a href=\"http:\/\/pecl.php.net\/package\/memcache\" target=\"_blank\" rel=\"noopener\">http:\/\/pecl.php.net\/package\/memcache<\/a>\u4e0b\u8f7d\u6e90\u7801\u5305\u81ea\u5df1\u7f16\u8bd1\u3002<\/p>\n<p>1 ##\u5378\u8f7dmemcache<\/p>\n<p>2 sudo pecl uninstall memcache<\/p>\n<p>3\u00a0phpize<\/p>\n<p>4\u00a0.\/configure &#8211;enable-memcache &#8211;with-php-conf=\/usr\/local\/php\/bin\/php-config<\/p>\n<p>5\u00a0make<\/p>\n<p>6\u00a0make install<\/p>\n<p>\u542f\u52a8memcached\u670d\u52a1\uff1amemcached -d -m 256 -p 11211\u3002\u6d4b\u8bd5\u811a\u672c\uff1aOK\u3002<\/p>\n<p>1 $mem = new Memcache;<\/p>\n<p>2 $mem-&gt;connect(&#8216;127.0.0.1&#8217;,11211);<\/p>\n<p>3 $mem-&gt;set(&#8216;lnla&#8217;,&#8217;blog&#8217;);<\/p>\n<p>4 var_dump( $mem-&gt;get(&#8216;lnla&#8217;) );<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u8f7d\u76ee\u524d\u6700\u65b0\u7684PHP5.4.8\u7f16\u8bd1\u540e(fpm)\uff0c\u4f7f\u7528sudo apt-get install memcache &hellip; <a href=\"https:\/\/www.lnlog.cn\/index.php\/2013\/07\/03\/memcache-problems\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">PHP5.4.x\u548cMemcache\u7684\u7248\u672c\u4e0d\u517c\u5bb9\u95ee\u9898<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[57],"class_list":["post-476","post","type-post","status-publish","format-standard","hentry","category-tech","tag-memcache"],"_links":{"self":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts\/476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=476"}],"version-history":[{"count":0,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts\/476\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}