±¾ÎĽ²ÊoÁËLinuxϱaÒeredisºÍphpredisµÄ½¨¡£*ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼£¬¾ßÌaÈçÏ£º
1¡¢×¼±¸¹¤×÷
ÏÂÔØÈi¼þ£º±¾Õ¾ÏÂÔصØÖ*¡£
²Ù×÷ϵͳ£ºCentOS 5.5
redis °ae±¾£ºredis-2.6.9
2¡¢±aÒe°²×°
tar zxvf redis-2.6.9.tar.gz //½aѹ
cd redis-2.6.9
make //±aÒe
Èç¹u³oÏÖÈçÏ´iÎo£º
zmalloc.o: In function zmalloc_used_memory': /data/redis-2.6.9/src/zmalloc.c:223: undefined reference to
__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: [redis-server] Error 1
make[1]: Leaving directory `/data/redis-2.6.9/src'
make: [all] Error 2
½a¾o½¨£º
make CFLAGS="-march=i686"
µ±¿´¼u¡°Hint: To run 'make test' is a good idea ;)¡± ˵Ã÷±aÒe³É¹¦¡£
make install //°²×°
˵Ã÷£ºÆaʵ make install ¾ÍÊÇ£º
cp -p redis-server /usr/local/bin
cp -p redis-benchmark /usr/local/bin
cp -p redis-cli /usr/local/bin
cp -p redis-check-dump /usr/local/bin
cp -p redis-check-aof /usr/local/bin
ÕaÑu£¬redis ¾Í°²×°³É¹¦ÁË¡£
½ÓÏÂÀ´¾ÍÊÇÆo¶¯RedisÁË, ÉÏÃae±aÒeºoÉu³ÉµÄÄÇÐ(C)¿ÉÖ´ÐÐÎļþ¿½±´µ½ÁË/usr/local/binĿ¼ÏÂÃae, ËuÃǵÄ×÷ÓÃ*Ö±ðÊÇ£º
redis-server£ºRedis*þÎñÆ÷µÄdaemonÆo¶¯³ÌÐo
redis-cli£ºRedisÃuÁiÐвÙ×÷¹¤¾ß¡£µ±È»£¬ÄaÒ²¿ÉÒÔÓà telnet ¸u¾ÝÆa´¿Îı¾ÐÒeÀ´²Ù×÷
redis-benchmark£ºRedisÐÔÄܲaÊÔ¹¤¾ß£¬²aÊÔRedisÔÚÄaµÄϵͳ¼°ÄaµÄÅaÖÃϵĶÁдÐÔÄÜ
Æo¶¯ Redis ½ø³ÌÖ»ÐeÒªÖ´ÐÐÕa¸o /usr/local/bin/redis-server /path-to/redis.conf
Æo¶¯µÄʱºoºoÃaeÒª¸uÉÏ redis µÄÅaÖÃÎļþ£¬ ÕaÑuRedis¾Í˳ÀuÆo¶¯ÁË.
3¡¢Æo¶¯ redis »a³oÏÖµÄÎÊÌa
Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
½a¾o½¨£ºÐÞ¸ÄÅaÖÃÎļþ redis.conf ½« maxmemory ÉeÖÃΪ maxmemory 1024000000 #*ÖÅa256MÄÚ´ae
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
½a¾o½¨£º¾¯¸ae£º¹ýÁ¿Ê¹ÓÃÄÚ´aeÉeÖÃΪ0£¡ÔÚµÍÄÚ´ae»*¾³Ï£¬ºǫ±£´ae¿ÉÄÜʧ°Ü¡£ÎªÁËÐÞÕýÕa¸oÎÊÌa£¬ÇeÔÚ/etc/sysctl.conf Ìi¼ÓÒ»Ïi 'vm.overcommit_memory = 1' £¬È»ºoÖØÆo£¨»oÕßÔËÐÐÃuÁi'sysctl vm.overcommit_memory=1' £(C)ʹÆaÉuЧ¡£
µ±Æo¶¯µÄʱºoûÓÐÈκÎÐÅÏ¢£¬±iÃ÷Æo¶¯³É¹¦¡£Ò²¿ÉÒÔʹÓà "netstat -tnl" ²e¿´6379¶Ë¿ÚÊÇ*ñÆo¶¯¡£
4¡¢¿ªÆoºÍ¹Ø±Õ redis
redis-server /usr/local/redis-2.6.9/redis.conf ¿ªÆo£¬×¢£ºÐeÒªÖ¸¶¨ redis µÄÅaÖÃÎļþ
pkill redis-server ֹͣ redis
redis-cli shutdown ֹͣ redis
5¡¢redis.conf µÄ²ÎÊýÐÅÏ¢
¹ØÓÚredis¼°Æa²ÎÊýÐÅÏ¢¿É²Î¿¼±¾Õ¾¡¶Redis»u±¾ÖªÊ¶¡¢°²×°¡¢²¿Êð¡¢ÅaÖñʼǡ*
6¡¢±aÒe phpredis
unzip phpredis-master.zip
cd phpredis-master
/usr/local/php/bin/phpize
./configure ¨Cwith-php-config=/usr/local/php/bin/php-config
make && make install
ÐÞ¸Ä php.ini Îļþ¡£¼ÓÔØ redis.so Ä£¿e£¬ÖØÆo Apache £¡
¸u¶a¹ØÓÚPHPÏa¹ØÄÚÈݸÐÐËȤµÄ¶ÁÕ߿ɲe¿´±¾Õ¾×¨Ìa£º¡¶php curlÓÃ*¨×ܽa¡¡¢¡¶[PHPÔËËaÓeÔËËauÓè×ܽa](http://www.jb51.net/Special/357.htm)¡¡¢¡¶PHPÍøÂç±a³Ì¼¼ÇÉ×ܽa¡¡¢¡¶[PHP»u±¾Ói¨ÈeÃŽ̳Ì](http://www.jb51.net/Special/348.htm)¡¡¢¡¶php²Ù×÷officeÎĵµ¼¼ÇÉ×ܽa(°uÀ¨word,excel,access,ppt)¡¡¢¡¶phpÈÕÆÚÓeʱ¼aÓÃ*¨×ܽa¡¡¢¡¶phpÃaeÏo¶ÔÏo³ÌÐoÉe¼ÆÈeÃŽ̡̳¡¢¡¶php×Öu´®(string)Óè×ܽa¡¡¢¡¶php+mysqlÊý¾Ý¿a²Ù×÷ÈeÃŽ̡̳¼°¡¶php³£¼uÊý¾Ý¿a²Ù×÷¼¼ÇÉ»a×Ü¡*
Ï£Íu±¾ÎÄËuÊo¶Ô´o¼ÒPHP³ÌÐoÉe¼ÆÓÐËu°iÖu¡£