LinuxÏÂMemcache·þÎñÆ÷¶ËµÄ°²×°
·þÎñÆ÷¶ËÖ÷ÒªÊÇ°²×°memcache·þÎñÆ÷¶Ë£¬Ä¿Ç°µÄ×îа汾ÊÇ memcached-1.3.0 ¡£ ÏÂÔØ£ºhttp://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz ÁíÍ⣬MemcacheÓõ½ÁËlibeventÕâ¸ö¿âÓÃÓÚSocketµÄ´¦Àí£¬ËùÒÔ»¹ÐèÒª°²×°libevent£¬libeventµÄ×îа汾ÊÇlibevent-1.3¡££¨Èç¹ûÄãµÄϵͳÒѾ°²×°ÁËlibevent£¬¿ÉÒÔ²»Óð²×°£© ¹ÙÍø£ºhttp://www.monkey.org/~provos/libevent/ ÏÂÔØ£ºhttp://www.monkey.org/~provos/libevent-1.3.tar.gz
ÓÃwgetÖ¸ÁîÖ±½ÓÏÂÔØÕâÁ½¸ö¶«Î÷.ÏÂÔØ»ØÔ´Îļþºó¡£ 1.ÏÈ°²×°libevent¡£Õâ¸ö¶«Î÷ÔÚÅäÖÃʱÐèÒªÖ¸¶¨Ò»¸ö°²×°Â·¾¶£¬¼´./configure ¨Cprefix=/usr£»È»ºómake£»È»ºómake install£» 2.ÔÙ°²×°memcached£¬Ö»ÊÇÐèÒªÔÚÅäÖÃʱÐèÒªÖ¸¶¨libeventµÄ°²×°Â·¾¶¼´./configure ¨Cwith-libevent=/usr£»È»ºómake£»È»ºómake install£» ÕâÑù¾ÍÍê³ÉÁËLinuxÏÂMemcache·þÎñÆ÷¶ËµÄ°²×°¡£ÏêϸµÄ·½·¨ÈçÏ£º
1.·Ö±ð°ÑmemcachedºÍlibeventÏÂÔØ»ØÀ´£¬·Åµ½ /tmp Ŀ¼Ï£º # cd /tmp # wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz # wget http://www.monkey.org/~provos/libevent-1.2.tar.gz
2.ÏÈ°²×°libevent£º # tar zxvf libevent-1.2.tar.gz # cd libevent-1.2 # ./configure ¨Cprefix=/usr # make # make install
3.²âÊÔlibeventÊÇ·ñ°²×°³É¹¦£º # ls -al /usr/lib | grep libevent lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3 -rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent-1.2.so.1.0.3 -rw-r¨Cr¨C 1 root root 454156 11?? 12 17:38 libevent.a -rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.la lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent.so -> libevent-1.2.so.1.0.3 »¹²»´í£¬¶¼°²×°ÉÏÁË¡£
4.°²×°memcached£¬Í¬Ê±ÐèÒª°²×°ÖÐÖ¸¶¨libeventµÄ°²×°Î»Ö㺠# cd /tmp # tar zxvf memcached-1.2.0.tar.gz # cd memcached-1.2.0 # ./configure ¨Cwith-libevent=/usr # make # make install Èç¹ûÖмä³öÏÖ±¨´í£¬Çë×Ðϸ¼ì²é´íÎóÐÅÏ¢£¬°´ÕÕ´íÎóÐÅÏ¢À´ÅäÖûòÕßÔö¼ÓÏàÓ¦µÄ¿â»òÕß·¾¶¡£ °²×°Íê³Éºó»á°Ñmemcached·Åµ½ /usr/local/bin/memcached £¬
5.²âÊÔÊÇ·ñ³É¹¦°²×°memcached£º # ls -al /usr/local/bin/mem* -rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached -rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/local/bin/memcached-debug
°²×°MemcacheµÄPHPÀ©Õ¹ 1.ÔÚhttp://pecl.php.net/package/memcache Ñ¡ÔñÏàÓ¦ÏëÒªÏÂÔصÄmemcache°æ±¾¡£ 2.°²×°PHPµÄmemcacheÀ©Õ¹
tar vxzf memcache-2.2.1.tgz cd memcache-2.2.1 /usr/local/php/bin/phpize ./configure ¨Cenable-memcache ¨Cwith-php-config=/usr/local/php/bin/php-config ¨Cwith-zlib-dir make make install
3.ÉÏÊö°²×°Íêºó»áÓÐÀàËÆÕâÑùµÄÌáʾ£º
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
4.°Ñphp.iniÖеÄextension_dir = ¡°./¡±ÐÞ¸ÄΪ
extension_dir = ¡°/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/¡±
5.Ìí¼ÓÒ»ÐÐÀ´ÔØÈëmemcacheÀ©Õ¹£ºextension=memcache.so
memcachedµÄ»ù±¾ÉèÖ㺠1.Æô¶¯MemcacheµÄ·þÎñÆ÷¶Ë£º # /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached.pid
-dÑ¡ÏîÊÇÆô¶¯Ò»¸öÊØ»¤½ø³Ì£¬ -mÊÇ·ÖÅä¸øMemcacheʹÓõÄÄÚ´æÊýÁ¿£¬µ¥Î»ÊÇMB£¬ÎÒÕâÀïÊÇ10MB£¬ -uÊÇÔËÐÐMemcacheµÄÓû§£¬ÎÒÕâÀïÊÇroot£¬ -lÊǼàÌýµÄ·þÎñÆ÷IPµØÖ·£¬Èç¹ûÓжà¸öµØÖ·µÄ»°£¬ÎÒÕâÀïÖ¸¶¨ÁË·þÎñÆ÷µÄIPµØÖ·192.168.0.200£¬ -pÊÇÉèÖÃMemcache¼àÌýµÄ¶Ë¿Ú£¬ÎÒÕâÀïÉèÖÃÁË12000£¬×îºÃÊÇ1024ÒÔÉϵĶ˿ڣ¬ -cÑ¡ÏîÊÇ×î´óÔËÐеIJ¢·¢Á¬½ÓÊý£¬Ä¬ÈÏÊÇ1024£¬ÎÒÕâÀïÉèÖÃÁË256£¬°´ÕÕÄã·þÎñÆ÷µÄ¸ºÔØÁ¿À´É趨£¬ ±¾ÐÂÎŹ² 2Ò³,µ±Ç°ÔÚµÚ 1Ò³ 1 2 |