1. Installing gcc dependencies
Since redis is developed in C language, you must first confirm whether the gcc environment (gcc -v) is installed before installation. If it is not installed, execute the following command to install it.
# yum install -y gcc
2. Download and install
# wget http://download.redis.io/releases/redis-5.0.3.tar.gz # tar -zxvf redis-5.0.3.tar.gz
3. Switch to the decompression directory and compile
# cd redis-5.0.3 # make
4. Install to the specified directory
# make install PREFIX=/usr/local/redis
5. Firewall settings
# firewall-cmd --zone=public --add-port=6379/tcp --permanent # firewall-cmd --reload # firewall-cmd --zone=public --query-port=6379/tcp
1. Front desk startup
# cd /usr/local/redis/bin/ # ./redis-server
2. Background startup
Copy redis.conf from the redis source code directory to the redis installation directory
# cp /home/ptcvi/redis-5.0.3/redis.conf /usr/local/redis/bin/ # vi redis.conf
Modify the redis.conf file and change daemonize no to daemonize yes
Add IP
Background startup
# ./redis-server redis.conf
Add startup service
# vi /etc/systemd/system/redis.service
Copy and paste 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 is configured to the installation path
Create redis command Soft link
# ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis
Set up startup
# systemctl daemon-reload # systemctl enable redis.service # systemctl start redis.service
Find the redis.windows.conf configuration in the redis root directory file, search for requirepass, find the comment password line, and add the password as follows:
# requirepass foobared requirepass redis#123 //注意,行前不能有空格
Restart the service
#systemctl restart redis.service
启动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
The above is the detailed content of How to deploy Redis5.0.3 on CentOS7.6. For more information, please follow other related articles on the PHP Chinese website!