1:redis Installation
$ wget http://download.redis.io/releases/redis-2.8.13.tar.gz $ tar xzf redis-2.8.13.tar.gz $ cd redis-2.8.13 $ make
2: Run Redis-loaded redis configuration file redis.conf
After compiling the executable file in the SRC directory, you can use the following command to run Redis: $ src/redis-server redis.conf You can use the built-in client connection Redis: $ src/ REDIS-CLI redis> set foo bar ok redis> get foo "Bar"
3:redis Configuration
(This is my personal configuration, according to their own needs configuration, remember to restart Redis and load the configuration) # Daemonize No by default, Redis is not running in the background, and if it needs to run in the background, change the value of the item to Yes Daemonize Yes # When Redis is running in the background, Redis defaults to placing the PID file in/var/run/redis.pid, which you can configure to a different address. Pidfile/var/run/redis.pid # Specifies the port on which Redis runs, by default 6379 port 6379 # Specifies that Redis receives only requests from that IP address, and if not set, all requests will be processed, # It is best to set the item in a production environment # bind 127.0.0.1 # Sets the time-out period in seconds for client connections. When the client does not issue any instructions during this time, close the connection # 0 is to turn off this setting timeout 0 # Specify logging level # Redis supports four levels in total: Debug, verbose, notice, warning, default = verbose # D Ebug records a lot of information for developing and testing # Varbose useful information, unlike debug will record so many # notice ordinary verbose, often used in production environments # warning only very important or critical information is logged to the log loglevel debug # config log file address # Default value is stdout, standard output, if background mode is output to/dev/null #logfile stdout Logfile/var/log/redis/redis.log # Number of available databases # default value is 16 , the default database is 0, and the database range is databases 16 ################################ snapshots between 0-(database-1) ################################# # # Save data to disk in the following format: # # Save <seconds> <changes> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # equivalent to the condition trigger fetch snapshot, this can be multiple conditions with # #, such as the default configuration file settings, set three conditions# Save 900 1 900 seconds at least 1 key changed # Save 300 10 300 seconds at least 300 key changed # Save 60 10000 60 seconds at least 10,000 key changed save 900 1 Save 60 10000 # when storing to a local database (persisted to an RDB file) whether the data is compressed, the default is Yes rdbcompression Yes # Local persistent database file name, default value is Dump.rdb Dbfil ENAME Dump.rdb # Working Directory # # The path to the file placement of the database mirroring backup. # The path here is configured separately from the file name because Redis writes the status of the current database to a temporary file when it is being backed up, and when the backup is complete, # replaces the temporary file with the file specified above. The temporary files here and the backup files configured above will be placed in the specified path. # # # # # # # # # # # # # # # # # # # # # AOF files will also be stored in this directory # # # # # Set the maximum number of client connections at the same time, the default is no limit, Redis can open the number of client connections for the Redis process can open the maximum number of file descriptors, # If set maxclients 0, indicating no restrictions. # when the number of client connections reaches the limit, Redis closes the new connection and returns max number of clients reached error message to the client # # MaxClients 128
4:php Installing the Redis extension above
$ wget https://github.com/owlient/phpredis/archive/master.zip $ unzip phpredis-master $ cd Phpredis-master $/usr/local/webserver/php/bin/phpsize (phpsize under the bin of your PHP installation directory) $./configure--with-php-config=/usr/ Local/webserver/php/bin/php-config $ make $ make install
5: Modify the PHP configuration file php.ini
$ vim/usr/local/webserver/php/php.ini (your php config file php.ini) Add a configuration: extension=redis.so reboot Apache or Nginx
6: Problems that may occur during installation
configuring for: PHP API Version: 20041225 Zend Module API No: 20060613 Zend Extension API No: 220060519 cannot find autoconf. Please check your autoconf installation and the $PHP _autoconf environment variable are set correctly and then Reru n this script. Workaround: $ wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz $ tar-zvxf m4-1.4.9.tar.gz $ cd m4-1.4.9/ $./configure && make && make install $ CD. / $ wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz $ tar-zvxf autoconf-2.62.tar.gz $ cd autoconf-2.62/ $./configure && make && make install