Install redis, php-redis, and centosredis in centos in Linux.
Source Address: http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm // This is centos 6
Install and enter the following command:
Step 1:
# Wget http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm# rpm-ivh epel-release-6-8.noarch.rpm # yum install redis php-redis #/etc/init. d/redis start // redis started successfully
Step 2:
# Vim/etc/sysconfig/iptables // configure the firewall #-a input-p tcp-m tcp -- dport 6379-j ACCEPT // Add this line in iptables, open Port 6379 (6379 is the default port of redis) # service iptables restart // restart the service
Step 3:
# Vim/etc/redis. conf // open the redis configuration file # bind 127.0.0.1 // note, that is, add # Number --- accessible from the Internet # service redis restart // restart the service
Step 4:
# Cd/usr/lib64/php/modules/# echo 'extension = redis. so '>/etc/php. d/redis. ini // introduce redis. so # vim/etc/php. d/redis. ini // remove the single quotation marks (that is, remove the comment) # service httpd restart // restart Apache
Test:
# Redis-cli redis 127.0.0.1: 6379> set a "Hello" // value: OK redis 127.0.0.1: 6379> get a "Hello" // Value
Php code:
<?php$redis = new Redis();$redis->connect('127.0.0.1',6379);$redis->set('a','Hello');echo $redis->get('a');?>
Ps: Windows
Cmd: https://github.com/dmajkic/redis/downloads
Service Installation Package: https://github.com/rgl/redis/downloads