Installation and use of redis under Linux (transfer)

 Respect originality: https://www.cnblogs.com/codersay/p/4301677.html , and correct the following red words

 

 

   Redis official website address: http://www.redis.io/

     Latest version: 2.8.3

     Installing Redis under Linux is very simple. The specific steps are as follows (the official website has instructions):

     1. Download the source code, decompress it and compile the source code.

$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz

$ tar xzf redis-2.8.3.tar.gz

$ cd redis-2.8.3

$ make

     2. After the compilation is completed, there are four executable files redis-server, redis-benchmark, redis-cli and redis.conf in the Src directory. Then copy to a directory.

mkdir /usr/redis

cp redis-server  /usr/redis

cp redis-benchmark   /usr/redis

cp redis-cli /usr/redis

cp redis.conf /usr/redis   ( this file does not exist, it needs to be downloaded and imported from other places )

cd /usr/redis

     3. Start the Redis service.

$ redis-server redis.conf   is not the previous command, it is the latter command to start ( ./redis-server )

     4. Then use the client to test whether the startup is successful.

$ redis-cli    (./redis-cli)

redis> set foo bar

OK

redis> get foo

"bar"

 

 

 

 

If the installation process appears (refer to:  http://blog.csdn.net/luyee2010/article/details/18766911 )

wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz

sudo tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/

cd /usr/local/tcl8.6.1/unix/

sudo ./configure

sudo make

sudo make install

 

 

 

[html] view plaincopy

  1. vi /etc/redis.conf  
  2. #Find daemonize no to change to  
  3. #Run as a daemon  
  4. daemonize yes  
  5. #Modify dir ./ to absolute path,  
  6. #By default, redis-server will generate or read dump.rdb in the current directory when it starts  
  7. #So if you execute redis-server /etc/redis.conf in the root directory,  
  8. #Read the dump.rdb in the root directory, so that redis-server can be executed in any directory  
  9. #So change dir to absolute path here  
  10. dir /usr/local/redis  
  11. #Modify appendonly to yes  
  12. #Specify whether to log after each update operation,  
  13. #Redis writes data to disk asynchronously by default,  
  14. #If not turned on, it may cause data loss for a period of time when power is lost.  
  15. #Because redis itself synchronizes data files according to the save conditions above,  
  16. #So some data will only exist in memory for a period of time. Default is no  
  17. appendonly yes  
  18. #Add redis to self-startup  
  19. echo "/usr/local/bin/redis-server /etc/redis.conf"  >>  /etc/rc.d/rc.local  
  20. #start redis  
  21. redis-server /etc/redis.conf  
  22. #Check if redis has been started  
  23. ps -ef | grep redis  

2>【Open redis port】

[html] view plaincopy

  1. #Turn off the firewall  
  2. service iptables stop  
  3. vi /etc/sysconfig/iptables  
  4. #Add to  
  5. -A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT  
  6. #Restart firewall  
  7. service iptables restart  

3>[Install phpredis extension]

[html] view plaincopy

  1. tar -zxvf owlient-phpredis-2.1.1-1-g90ecd17.tar.gz  
  2. cd owlient-phpredis-90ecd17  
  3. /usr/local/php/bin/phpize  
  4. ./configure --with-php-config=/usr/local/php/bin/php-config  
  5. make  
  6. make install  
  7. #After executing make install, it will be generated  
  8. #Installing shared extensions:     /usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/  
  9. #Modify php.ini  
  10. vi /usr/local/php/etc/php.ini  
  11. #Find extension_dir and modify it to  
  12. extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"  
  13. #Add redis  
  14. extension = redis.so  
  15. # restart apache  
  16. service httpd restart  
Knowledge shapes life, and programs create the world. 7 and a half years of work experience, including 2 years of product experience, 5 and a half years of development experience, and half a year of team experience. I know that the best learning materials are official documents and experience accumulation.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324656512&siteId=291194637