Redis基礎學習基本結束,火燒眉毛的想嘗試一下php操做redis的快感,可是前提是先安裝phpredis擴展。:sweat_smile:php
這是在問答裏頭一哥們給推薦的,事實證實很好用。
地址:https://github.com/phpredis/phpredisgit
由於這個包是zip壓縮的,因此咱們使用unzip解壓。
[root@myCentos lamp]# unzip phpredis-develop.zipgithub
根據文檔提示,這時候phpize應該出場了,我去,它是什麼鬼?
還好百度知道:phpize是用來擴展php擴展模塊的,經過phpize能夠創建php的外掛模塊。
可是個人php當時是用yum安裝的,貌似沒有安裝這個文件。因此如今須要先安裝它,圖省事,就yum安裝了。
命令:yum install php-develredis
真是見了鬼了,一直報出以下錯誤:apache
Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
無奈,只好在網上搜索答案,通常都說是yum源出的問題。最關鍵的是repository後面的提示信息:epel。
結合網上給出的答案,貌似找到了解決方法:vim
cd /etc/yum.repos.d vim epel.repo [epel] 2 name=Extra Packages for Enterprise Linux 6 - $basearch 3 #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch 4 mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch 5 failovermethod=priority 6 enabled=1 \#把這裏原來的1,改爲0便可 7 gpgcheck=1 8 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 yum clean all
把原來的enabled=1改爲enabled=0
而後yum安裝就正常了。
再回到剛纔的話題,php-devel安裝好了以後,使用whereis查看該命令在什麼地方。以下:學習
[root@myCentos yum.repos.d]# whereis phpize phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz
進入剛纔解壓好的文件夾,而後運行phpize,以便生成configure。ui
[root@myCentos lamp]# cd phpredis-develop [root@myCentos phpredis-develop]# /usr/bin/phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626
結束以後就可使用命令:
./configure --with-php-config=/usr/bin/php-config
注意:個人php-config是在/usr/bin/下,具體還要根據本身的實際狀況來,能夠用whereis找一下。url
[root@myCentos phpredis-develop]# make && make install
完成安裝注意看最後幾行:.net
Build complete. Don't forget to run 'make test'. Installing shared extensions: /usr/lib/php/modules/
安裝成功,而且還告訴了咱們redis.os的位置。
在php.ini中添加擴展
extension=redis.so
由於修改了配置文件,須要重啓apache。
命令:service httpd restart
而後訪問phpinfo頁面,若是可以找到redis擴展,就說明安裝成功。
此刻,就能夠只用php操做redis了。
學PHP的小螞蟻 原創博客 http://my.oschina.net/woshixiaomayi/blog