: Http://redis.io/download to download the latest version of the document.
1. Download and install
sudo wget http://download.redis.io/releases/redis-3.2.9.tar.gz
sudo tar-zxvf redis-3.2.9.tar.gz
sudo cd redis-3.2.9
sudo make
sudo make Prefix=/usr/local/redis install
2. Configuration
sudo mkdir/usr/local/redis/etc/
sudo vim/usr/local/redis/etc/redis.conf//write the following:
Daemonize Yes
Pidfile/usr/local/redis/var/redis.pid
Port 6379
Timeout 300
LogLevel Debug
Logfile/usr/local/redis/var/redis.log
Databases 16
Save 900 1
Save 300 10
Save 60 10000
Rdbcompression Yes
Dbfilename Dump.rdb
dir/usr/local/redis/var/
AppendOnly No
Appendfsync always
The following are the meanings of the main configuration parameters of redis.conf:
Daemonize: Whether to run daemon mode later
Pidfile:pid File Location
Port: Port number for listening
Timeout: Request time-out
Loglevel:log Information level
Logfile:log File Location
Databases: number of open databases
Save *: How often the snapshot is saved, the first * indicates how long, and the third * indicates how many times the write operation is performed. Snapshots are automatically saved when a certain number of writes are performed within a certain amount of time. You can set multiple conditions.
Rdbcompression: Whether to use compression
Dbfilename: Data Snapshot file name (only file name, excluding directory)
Dir: Save directory for Data snapshot (this is the directory)
AppendOnly: If the appendonlylog is turned on, each write will record a log, which will improve the data anti-risk ability, but affect the efficiency.
Appendfsync:appendonlylog How to sync to disk (three options, each write is forced to call Fsync, Fsync per second, do not call Fsync wait for the system to synchronize itself)
sudo mkdir/usr/local/redis/var/
sudo chmod 777/usr/local/redis/var/
The commands to start Redis are:
Sudo/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis.conf
PS Axu |grep Redis
NETSTAT-TUNLP |grep Redis
Once the Redis service process is started, you can use the test client program REDIS-CLI to interact with the Redis service. Like what:
$ cd src$./Redis-Cliredis> SetFoo Barokredis> GetFoo"Bar"
PHP Installation Redis Extensions
The following operations need to be done in the downloaded Phpredis directory:
sudo wget http://pecl.php.net/get/redis-3.1.2.tgz
sudo tar-zxvf redis-3.1.2.tgz
CD redis-3.1.2
[Email protected] redis-3.1.2]$ sudo/usr/local/php/bin/phpize
Configuring for:
PHP Api version:20160303
Zend Module Api no:20160303
Zend Extension Api no:320160303
[email protected] redis-3.1.2]$ sudo./configure--with-php-config=/usr/local/php/bin/php-config
[[Email protected]er2 redis-3.1.2]$ sudo make
[[email protected] redis-3.1.2]$ sudo make install
Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
[email protected] redis-3.1.2]$ sudo vim/usr/local/php/etc/php.ini
Add the following content:
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303" extension = Redis . So
Restart the PHP-FPM or Nginx after the installation is complete. View the phpinfo information to see the Redis extension.
Or
Create *.ini files under/usr/local/php/etc/conf.d/to make it easier to manage PHP extension modules
Mkidr/usr/local/php/etc/conf.d/redis.ini
Extension = redis.so
Systemctl Restart Php-fpm.service//restart PHP service
Connect to the Redis service
sudo vim/usr/local/nginx/html/2.php
< ? Connect to the local Redis service
$redis Span style= "font-size:12px;font-family: ' Courier New '; Color:rgb (102,102,0); Background-color:rgb (251,251,251);" >= new Span style= "font-size:12px;font-family: ' Courier New '; Color:rgb (102,0,102); Background-color:rgb (251,251,251);" >redis ();
$redis -Connect(' 127.0.0.1 ', 6379);
Echo "Connection to server sucessfully" ; //See if the service is running
Echo"Server is running:" .$redis -Ping();?>
Curl localhost/2.php
Connection To server sucessfully
Server is running: PONG
Redis Installation and PHP extensions