1、下載安裝包:http://redis.io
2、安裝依賴
[root@centos6 ~] yum install -y cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make tcl
3、解壓安裝
[root@centos6 ~] tar -zxvf redis-6.0.6.tar.gz [root@centos6 ~] cd redis-6.0.6 [root@centos6 ~] make [root@centos6 ~] make test [root@centos6 ~] make install
出現問題:error: unrecognized command line option "-std=c11"
原因是gcc版本低,預設安裝的是4.4.7,而redis6需要更高的版本 >=4.9
可到到官網 http://ftp.gnu.org/gnu/gcc/ 下載4.9.4版本,手動安裝。
注意安裝gcc4.9.4版本還需要mpc、mpfr、gmp等依賴(MPFR=mpfr-2.4.2;GMP=gmp-4.3.2;MPC=mpc-0.8.1)。
安裝順序:gmp > mpfr > mpc
[root@centos6 ~] tar zxvf gmp-4.2.3.tar.gz [root@centos6 ~]# cd gmp-4.2.3 [root@centos6 gmp-4.2.3]# mkdir gmp-build [root@centos6 gmp-4.2.3]# cd gmp-build [root@centos6 gmp-build]# ../configure --prefix=/usr/local/gmp-4.2.3 [root@centos6 gmp-build]# make && make install
[root@centos6 ~] tar zxvf mpfr-2.4.2.tar.gz [root@centos6 ~]# cd mpfr-2.4.2 [root@centos6 mpfr-2.4.2]# mkdir mpfr-build [root@centos6 mpfr-2.4.2]# cd mpfr-build [root@centos6 mpfr-build]# ../configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.2.3 [root@centos6 mpfr-build]# make && make install
[root@centos6 ~] tar zxvf mpc-0.8.1.tar.gz [root@centos6 ~]# cd mpc-0.8.1 [root@centos6 mpc-0.8.1]# mkdir mpc-build [root@centos6 mpc-0.8.1]# cd mpc-build [root@centos6 mpc-build]# ../configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.2.3 --with-mpfr=/usr/local/mpfr-2.4.2 [root@centos6 mpc-build]# make && make install
儲存到環境變數:
[root@centos6 ~] vim /etc/profile export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.2.3/lib:/usr/local/mpfr-2.4.2/lib [root@centos6 ~] source /etc/profile
安裝GCC
[root@centos6 ~] tar -xzf gcc-4.9.4.tar.gz [root@centos6 ~] cd gcc-4.9.4 [root@centos6 gcc-4.9.4] mkdir gcc-build [root@centos6 gcc-4.9.4] cd gcc-build [root@centos6 gcc-build] ../configure --prefix=/usr/local/gcc-4.9.4 --disable-multilib --disable-checking --enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.2.3 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 [root@centos6 gcc-build] make -j4 && make install
調整gcc相關命令:
[root@centos6 ~] mv /usr/bin/gcc /usr/bin/gcc-4.9.4 [root@centos6 ~] ln -s /usr/local/gcc-4.9.4/bin/gcc /usr/bin/gcc [root@centos6 ~] /usr/bin/gcc -v [root@centos6 ~] mv /usr/bin/g++ /usr/bin/g++-4.9.4 [root@centos6 ~] ln -s /usr/local/gcc-4.9.4/bin/g++ /usr/bin/g++ [root@centos6 ~] mv /usr/bin/c++ /usr/bin/c++-4.9.4 [root@centos6 ~] ln -s /usr/local/gcc/bin-4.9.4/c++ /usr/bin/c++
4、繼續安裝redis6,安裝完成後修改配置檔案
[root@centos6 ~]# vim redis.conf #修改配置檔案 protected-mode no # 關閉保護模式 daemonize yes # 守護程式模式開啟 bind 127.0.0.1 # 繫結IP按需修改 port 6379 # 埠按需修改
5、啟動
[root@centos6 redis6.0.6]# ./src/redis-server redis.conf #啟動服務命令 [root@centos6 redis6.0.6]# netstat -tunpl | grep 6379 #檢視6379埠是否佔用