經由過程pkg安裝,最高只能安裝redis-4.0.11。既然redis已經發布了最新版本5.0.3。這里就測驗考試安裝一下redis的最新版本。
一、到redis官網https://redis.io/下載Redis 5.0.3 is the latest stable version。
二、解壓縮并進入將解壓后的文件夾
#cd redis-5.0.3
#gmake
#gmake install clean
如許將會把redis默認安裝到/usr/local/bin中,當然你也可以經由過程下面號令進行安裝:
#gmake PREFIX=/usr/local/share/redis-5 install clean
經由過程加上PREFIX=/usr/local/share/redis-5可以把redis安裝到/usr/local/share/redis-5目次中。
三、對redis進行設置裝備擺設
把redis-5.0.3文件夾中的redis.conf拷貝到/usr/local/etc文件夾下:
#cp redis.conf /usr/local/etc/redis_6379.conf
然后對它進行一些點竄:
#ee /usr/local/etc/redis_6379.conf
點竄下面三行內容:
damemonize yes //在自啟動redis時不顯示daemon
logfile /var/log/redis/redis.log //日記保留目次
dir /home/redis_db/6379 //數據庫保留目次
當然在更改上面兩個目次前必然要先建立響應的目次,不然redis-server將無法啟動。
#mkdir /var/log/redis
#mkdir /home/redis_db
#mkdir /home/redis_db/6379
四、在/usr/local/etc/rc.d目次中建立redis開機啟動文件
#cd /usr/local/etc/rc.d
#touch redis_6379 //建立開機啟動文件
#chmod 555 redis_6379 //將開機啟動文件屬性改當作可執行文件
#ee redis_6379 //點竄開機啟動文件
將下面的內容復制到redis_6379文件中并保留:
#!/bin/sh
#
# $FreeBSD: branches/2018Q4/databases/redis/files/redis.in 401020 2015-11-07 20:08:18Z osa $
#
# PROVIDE: redis
# REQUIRE: LOGIN
# BEFORE: securelevel
# KEYWORD: shutdown
# Add the following line to /etc/rc.conf to enable `redis':
#
#redis_6379_enable="YES"
#
# Define profiles here to run separate redis instances:
#
#redis_profiles="foo bar" # Script uses /usr/local/etc/redis-NAME.conf respectively.
# For correct script working please update pidfile entries in
# redis-NAME.conf files.
. /etc/rc.subr
name="redis_6379"
rcvar="${name}_enable"
extra_commands="reload"
command="/usr/local/bin/redis-server"
pidfile="/var/run/redis/$name.pid"
# read configuration and set defaults
load_rc_config "$name"
: ${redis_6379_enable="NO"}
: ${redis_user="redis"}
: ${redis_config="/usr/local/etc/$name.conf"}
command_args="${redis_config}"
required_files="${redis_config}"
_profile_exists() {
for _p in ${redis_profiles}; do
[ "${_p}" = "$1" ] && return 1;
done
return 0
}
if [ $# -eq 2 ]; then
_profile=$2
_profile_exists $_profile
_exists=$?
[ ${_exists} -ne 1 ] && { echo "`basename /usr/local/etc/rc.d/redis`: no '$2' in 'redis_profiles'" exit 1 };
echo "-- Profile: ${_profile} --"
config_file="/usr/local/etc/${name}-${_profile}.conf"
command_args="${config_file}"
pidfile="/var/run/redis/${_profile}.pid"
required_files="${config_file}"
elif [ -n "${redis_profiles}" ]; then
_swap=$*; shift; _profiles=$*
_profiles=${_profiles:-${redis_profiles}}
set -- ${_swap}
for _profile in ${_profiles}; do
/usr/local/etc/rc.d/redis $1 ${_profile}
done
exit 0
fi
run_rc_command "$1
五、點竄/etc/rc.conf
#ee /etc/rc.conf
添加下行代碼:
redis_6379_enable="YES"
六、重啟電腦進行測試
OK,redis-5.0.3安裝完當作
0 篇文章
如果覺得我的文章對您有用,請隨意打賞。你的支持將鼓勵我繼續創作!