> 此安裝方式只適合centos
## 0. 先安裝tcl, 否則make test 會出錯
~~~
yum install tcl
~~~
## 1. 下載安裝, 這個沒什么好說的
~~~
wget http://download.redis.io/releases/redis-3.0.1.tar.gz
tar xzf redis-3.0.1.tar.gz
cd redis-3.0.1
make
make test
make install
~~~
## 2. 將redis添加到系統服務
~~~
vi /etc/rc.d/init.d/redis
-- 粘帖一下代碼
###########################
#chkconfig: 2345 10 90
#description: Start and Stop redis
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/etc/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
##############################
-- 添加可執行權限
chmod +x /etc/init.d/redis
-- 啟動redis
service redis start
-- 設置自啟動
chkconfig redis on
~~~
## 3. 配置防火墻
~~~
vi /etc/sysconfig/iptables
-- 添加配置
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT
-- 重啟防火墻
service iptables restart
~~~
## 4. 測試
~~~
redis-cli
set name shuai
"shuai"
get name
"shuai"
~~~
- Linux相關
- centos下源碼安裝redis的方法
- Nginx配置ThinkPHP的UrlRewrite和PathInfo模式
- Apache開啟 .htaccess & url_rewrite & vhost
- Ubuntu安裝服務器環境
- Virtual Box 和 Ubuntu Server 14.10 的共享文件
- www.hmoore.net服務器環境搭建
- Javascript相關
- Javascript導出Excel表格
- Javascript格式化時間戳
- 工具相關
- sublime text 3 安裝后要做的事
- 測試
- NetBeans默認使用utf8編碼打開文件方法
- sass安裝
- less安裝
- 各種查詢
- 蘋果常用軟件的url schemes查詢