This article will show you how to install Redis on Centos 7. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Without further ado, let’s get started.
redis is developed in C language. Before installation, you must first confirm whether the gcc environment is installed (gcc -v
) , if it is not installed, execute the following command to install it.
$ yum install -y gcc
$ wget http://download.redis.io/releases/redis-5.0.7.tar.gz $ tar -zxvf redis-5.0.7.tar.gz
$ cd redis-5.0.7 && make
$ make install PREFIX=/usr/local/redis
[Related recommendations: Redis video tutorial]
$ cd /usr/local/redis/bin/ $ ./redis-server
Copy redis.conf from the redis source code directory to The installation directory of redis
$ cp /usr/local/redis-5.0.7/redis.conf /usr/local/redis/bin/
Modify the redis.conf file and change daemonize no to daemonize yes
$ vim redis.conf ################################# GENERAL ##################################### # By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize yes
Background startup
$ ./redis-server redis.conf
Add startup service
$ vim /etc/systemd/system/redis.service
Add the following content
[Unit] Description=redis-server After=network.target [Service] Type=forking ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target
Note: ExecStart
Configure to your own path
Set startup
$ systemctl daemon-reload $ systemctl start redis.service $ systemctl enable redis.service
Create redis command soft link
$ ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis # 测试 $ redis 127.0.0.1:6379> ping PONG 127.0.0.1:6379>
Finally, post some common commands~
# 启动redis服务 systemctl start redis.service # 停止redis服务 systemctl stop redis.service # 重新启动服务 systemctl restart redis.service # 查看服务当前状态 systemctl status redis.service # 设置开机自启动 systemctl enable redis.service # 停止开机自启动 systemctl disable redis.service
OK~It’s done~
For more programming-related knowledge, please visit: Programming Video! !
The above is the detailed content of A brief discussion on how to install Redis on Centos 7. For more information, please follow other related articles on the PHP Chinese website!