How to install redis server on CentOS 7 / RHEL 7/windows10

windows10下的redis安装参考
Thinkphp 3.2.3 redis缓存
参考How To Configure a Redis Cluster on CentOS 7

转自:http://sharadchhetri.com/2014/10/04/install-redis-server-centos-7-rhel-7/

October 4, 2014
by Sharad Chhetri 2 Comments

In this tutorial we will learn, how to install redis server on CentOS 7 / RHEL 7 . The abbreviation of redis is REmote DIctionary Server. It is one the of the most popular open source,advanced key-value cache and store.
Project URL : http://redis.io/
Follow the given below steps to install redis server on CentOS 7 and Red Hat Enterprise Linux 7.

Install wget utility

Install wget command

yum install wget

Install EPEL repo

First we will install the EPEL repo. For more detail on EPEL repo, we suggest you to read our this post.
Because our system has x86_64 Operating System architecture, we will use only epel repo package for x86_64 . Search epel repo package as per your Operating System architecture(EPEL URL)

wget -r --no-parent -A 'epel-release-.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/
sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-
.rpm

It will create two epel’s repo file inside /etc/yum.repos.d
These are-

  1. epel.repo
  2. epel-testing.repo

[root@localhost ~]# ls -l /etc/yum.repos.d/
total 28-rw-r--r--. 1 root root 1612 Jul 4 07:00 CentOS-Base.repo
-rw-r--r--. 1 root root 640 Jul 4 07:00 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 1331 Jul 4 07:00 CentOS-Sources.repo
-rw-r--r--. 1 root root 156 Jul 4 07:00 CentOS-Vault.repo
-rw-r--r--. 1 root root 957 Sep 2 12:14 epel.repo
-rw-r--r--. 1 root root 1056 Sep 2 12:14 epel-testing.repo[root@localhost ~]#

Install redis server

Now use yum command to install redis server

sudo yum -y update
sudo yum -y install redis

Two important redis server configuration file’s path

  1. /etc/redis.conf
  2. /etc/redis-sentinel.conf

Now start the redis server after this.

sudo systemctl start redis.service

Check the running status of redis server

systemctl status redis.service

To test the installation of Redis, use below given command

redis-cli ping

If the response output is PONG, it means installation is completed successfully.

[root@localhost ~]# redis-cli ping
PONG
[root@localhost ~]#

Start/Stop/Restart/Status and Enable redis server

To start redis server

systemctl start redis.service

To stop redis server

systemctl stop redis.service

To restart redis server

systemctl restart redis.service

To get running status of redis server

systemctl status redis.service

To enable redis server at system’s booting time.

sudo systemctl enable redis.service

To disable redis server at system’s booting time.

sudo systemctl disable redis.service

Listening Port Of Redis Server

Redis Server listens by default at port number 6379.

[root@localhost ~]# ss -nlp|grep redis
tcp LISTEN 0 128 127.0.0.1:6379 : users:(("redis-server",19706,4))
[root@localhost ~]#

Set Up a Redis Server as a Session Handler for PHP

sudo ifconfig
sudo vi /etc/php-fpm.d/www.conf

Find the requirepass directive and set it to a strong passphrase.

requirepass yourverycomplexpasswordhere

sudo service php-fpm restart

redis-cli -h ip_to_contact_redis -p port_to_contact_redis

你可能感兴趣的:(How to install redis server on CentOS 7 / RHEL 7/windows10)