[root@localhost ~]# uname php
Linux c++
[root@localhost ~]# uname -r git
2.6.32-431.el6.i686 github
[root@localhost ~]# uname -a redis
Linux localhost 2.6.32-431.el6.i686 #1 SMP Fri Nov 22 00:26:36 UTC 2013 i686 i686 i386 GNU/Linux 數據庫
[root@localhost ~]# cat /etc/centos-release centos
CentOS release 6.5 (Final) 服務器
請到redis的官網下載最新的 http://redis.io/downloadide
這裏咱們下載不是最新的穩定版的2.8.6,3.0.0由於是Beta版本因此不推薦生產環境使用,開發環境嚐鮮仍是能夠的。工具
這裏經過 redis官網的 http://redis.io/clients 找到PhpRedis 去github上就能找到啦 https://github.com/nicolasff/phpredis ,這裏顯示的版本是2.2.4 。
安裝教程在redis的官網上就有,這裏詳細講一下。
下載網上的資源須要用到wget工具,有的同窗的服務器多是新裝的尚未來得及裝(好比我。。。)
#安裝wget
yum install wget
ok,而後開始安裝redis,順便說一句,鏈接外國網站真是慢的不得了,兩三次下載都卡住了 = =
$ wget http://download.redis.io/releases/redis-2.8.6.tar.gz
$ tar xzf redis-2.8.6.tar.gz
$ cd redis-2.8.6
$ make
而後。QAQ,make的時候又出現了錯誤
make[3]: gcc:命令未找到
看來沒有安裝gcc....
#安裝gcc
yum install gcc gcc-c++ kernel-devel
而後安裝的時候又發現出現了錯誤
zmalloc.h:50:31: 錯誤:jemalloc/jemalloc.h:沒有那個文件或目錄
zmalloc.h:55:2: 錯誤:#error "Newer version of jemalloc required"
而後去百度了,解決方案爲
make MALLOC=libc
接下來就是耐心等待,下面是我看到的結果。
Hint: To run 'make test' is a good idea ;)
make[1]: Leaving directory `/root/redis-2.8.6/src'
這樣就算安裝完成了。
請注意,若是你在make的時候出現上述的問題,那麼,在啓動redis服務的時候就要注意了
#官方網站提示這樣啓動服務
src/redis-server
#可是出現了上面的問題後,請用下面的方式啓動redis服務
nohup src/redis-server redis.conf &
啓動redis服務完成。
下面是簡單測試。
[root@localhost redis-2.8.6]# src/redis-cli
127.0.0.1:6379> ping
PONG
phpredis屬於php擴展,因此須要phpize,若是你的服務器沒有安裝phpize,要先安裝
#安裝phpize
yum install php-devel
直接用wget好了
#wget下載github上的文件
wget https://github.com/nicolasff/phpredis/archive/master.zip
下面要解壓zip文件,首先,你,要,有個,unzip....
#安裝了這麼多的軟件,想一想也該知道怎麼裝這個東西了吧
yum install unzip
#解壓
unzip master.zip
下面正式開始編譯php擴展
#1.準備phpize編譯環境
[root@localhost phpredis-master]# phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
再次ls就會發現文件夾中多了幾個配置文件
#2.配置環境
./configure
這個步驟會將上一步準備好的配置文件進行執行
#3.編譯
make && make install
balabala...........
#編譯完成
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/lib/php/modules/
進入/usr/lib/php/modules 文件夾,發現redis.so的擴展。
[root@localhost phpredis-master]# vi /etc/php.ini
添加下面的擴展
extension=redis.so
[root@localhost modules]# service httpd restart
中止 httpd: [肯定]
正在啓動 httpd: [肯定]
借用《七日七數據庫》中的一句話,redis就像是無處不在的潤滑油。
簡單,快速。
咱們從小到大,正是由於經歷了足夠多的事情纔會成長。