Redis Installation Finishing (window platform) +php extended RedisCategory: Web development 2013-03-23 18:51 8258 people read reviews (3) favorite reports
The main steps are to refer to Baidu before a few tutorials, but there are a few small problems in the middle, specifically to add:
Windows Platform Redis Installation
Redis Windows installation files : Http://code.google.com/p/servicestack/wiki/RedisWindowsDownload#Download_32bit_Cygwin_ Builds_for_windows
My choice of Redis is the latest version of the installation file, see:
after the Redis installation file is unpacked, there are several files. See
Redis-server.exe: Service Program
Redis-check-dump.exe: Local Database check
Redis-check-aof.exe: Update log check
Redis-benchmark.exe: Performance test to simulate the simultaneous sending of M-Sets/gets queries by n clients (similar to the Apache AB tool).
After extracting the Redis installation files to the E:\ root directory, you also need to add a Redis profile redis.conf to the Redis root directory, which is included in the file specific content, but here I still post the contents of the configuration file:
Configuration file
[HTML]View Plaincopy
- # Redis Configuration File Example
- # By default, Redis does not run as a daemon. Use the ' yes ' if you need it.
- # Note that Redis would write a PID file in/var/run/redis.pid when daemonized.
- Daemonize No
- # when run as a daemon, the Redis write a PID file in/var/run/redis.pid by default.
- # can specify a custom PID file location here.
- Pidfile/var/run/redis.pid
- # Accept connections on the specified port, default is 6379
- Port 6379
- # If you want your can bind a single interface if the BIND option isn't
- # specified all the interfaces would listen for connections.
- #
- # bind 127.0.0.1
- # Close The connection after a client are idle for N seconds (0 to disable)
- Timeout 300
- # Set Server verbosity to ' debug '
- # It can be one of:
- # Debug (a lot of information, useful for development/testing)
- # notice (moderately verbose, what are want in production probably)
- # warning (only very important/critical messages is logged)
- LogLevel Debug
- # Specify the log file name. Also ' stdout ' can is used to force
- # The demon to log in the standard output. Note If you use the standard
- # Output for logging but daemonize, logs'll be sent To/dev/null
- LogFile stdout
- # Set the number of databases. The default database is DB 0, you can select
- # A different one on a per-connection basis using SELECT <dbid> where
- # dbid is a number between 0 and ' databases '-1
- Databases 16
- ################################ snapshotting #################################
- #
- # Save the DB on disk:
- #
- # Save <seconds> <changes>
- #
- # would save the DB if both the given number of seconds and the given
- # Number of write operations against the DB occurred.
- #
- # in the example below the behaviour would be is to save:
- # After the SEC (min) If at least 1 key changed
- # After the SEC (5 min) If at least ten keys changed
- # after the SEC if at least 10000 keys changed
- Save 900 1
- Save 300 10
- Save 60 10000
- # Compress String objects using LZF when dump. RDB databases?
- # for default this ' s set to ' yes ' as it's almost always a win.
- # If you want to save some CPU on the saving child set it to ' no ' but
- # The DataSet would likely is bigger if you have compressible values or keys.
- Rdbcompression Yes
- # The filename where to dump the DB
- Dbfilename Dump.rdb
- # for Default Save/load DB in/from the working directory
- # Note that you must specify a directory is not a file name.
- Dir./
- ################################# REPLICATION #################################
- # Master-slave replication. Use slaveof to make a Redis instance a copy of
- # another Redis server. Note that the configuration was local to the slave
- # So for example it's possible to configure the slave to save the DB with a
- # different interval, or to listen to another ports, and so on.
- #
- # slaveof <masterip> <masterport>
- # If The master is password protected (using the "Requirepass" configuration
- # directive below) It's possible to tell the slave to authenticate before
- # Starting the replication synchronization process, otherwise the master would
- # refuse the slave request.
- #
- # Masterauth <master-password>
- ################################## SECURITY ###################################
- # Require clients to issue AUTH <PASSWORD> before processing all other
- # commands. This might is useful in environments in which don't trust
- # Others with access to the host running Redis-server.
- #
- # This should stay commented out for backward compatibility and because most
- # People do not need auth (e.g. they run their own servers).
- #
- # Requirepass Foobared
- ################################### LIMITS ####################################
- # Set The max number of connected clients at the same time. By default there
- # is no limit, and it's up to the number of file descriptors the Redis process
- # is able to open. The special value ' 0 ' means no limts.
- # Once The limit is reached Redis would close all the new connections sending
- # an error ' max number of clients reached '.
- #
- # maxclients 128
- # Don ' t use more memory than the specified amount of bytes.
- # maxmemory <bytes>
- AppendOnly No
- Appendfsync always
- Glueoutputbuf Yes
Extract the Redis_conf.rar from the attachment and place it in the root of the Redis. Here, the Redis installation is complete. Start using the Redis database below.
To start Redis:
Input command: Redis-server.exe redis.conf
After startup as shown:
Start the cmd window to remain open, and the Redis service shuts down when it is closed.
When the service is opened, another window is opened, and the client is set up:
Input command: redis-cli.exe-h 202.117.16.133-p 6379
Enter the following as shown:
Above the IP to write your own OH:
PHP Extended Redis Features
1 First, view the compiled version of PHP v6/v9 in Phpinfo ()
2 Download Extension Address: Https://github.com/nicolasff/phpredis/downloads (note the supported PHP versions)
3 Place the downloaded Php_redis.dll in the PHP extension directory (EXT) and modify the configuration file php.ini
When adding extensions, be sure to
Extension=php_igbinary.dllextension=php_redis.dll This sequence or restart Apache will appear, PHP startup error
4 Restart the service, view Phpinfo (), the following indicates success;
5 Testing with PHP
PHP code
[PHP]View Plaincopy
- $redis = new Redis ();
- $redis->connect ("192.168.138.2","6379"); //php Client-set IP and port
- Store a value
- $redis->set ("Say","Hello World");
- echo $redis->get ("say"); //should output Hello World
- Store multiple values
- $array = Array (' first_key ' = 'first_val ',
- ' second_key ' = 'second_val ',
- ' third_key ' = 'third_val ');
- $array _get = Array (' First_key ',' Second_key ',' Third_key ');
- $redis->mset ($array);
- Var_dump ($redis->mget ($array _get));
PHP Extended Redis