您好,登錄后才能下訂單哦!
下載redis
下載redis,解壓,編譯:
$ wget http://download.redis.io/releases/redis-4.0.6.tar.gz
$ tar xzf redis-4.0.6.tar.gz
$ cd redis-4.0.6
$ make && make PREFIX=/usr/local/redis install? #安裝到指定目錄
現(xiàn)在去剛剛tar包解壓出來的源碼目錄中,拷貝一個redis.conf配置文件,放到/usr/local/redis/bin/目錄下
進入到redis目錄下,運行vi redis.conf
將daemonize no改為 daemonize yes保存退出
通過下面的命令啟動Redis服務(wù):
./bin/redis-server ./redis.conf
你可以使用內(nèi)置的客戶端命令redis-cli進行使用:
$ ./redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
以上呢是安裝redis程序
在php7中要開啟redis擴展
使用git clone下載git上的phpredis擴展包
[root@localhost local ]# wget http://pecl.php.net/get/redis-3.1.3.tgz
[root@localhost local ]# sudo tar -zxvf? redis-3.1.3.tgz
[root@localhost local ]#?cd redis-3.1.3
到了這一步,我們要使用安裝php時生成的phpize來生成configure配置文件,
//具體用哪個要取決于你的phpize文件所在的目錄,這時你應(yīng)該用 whereis phpize 來查看路徑
[root@localhost local ]# whereis phpize
phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz
這里表明路徑為/usr/bin/phpize,然后執(zhí)行:
[root@localhost phpredis ]# /usr/bin/phpize
Can't find PHP headers in /usr/include/php
The php-devel package is required for use of this command.
這里報錯了,原因是沒有安裝好php-devel,由于我是使用的php7.0所以執(zhí)行以下命令:
[root@localhost phpredis]#yum -y install php70w-devel
然后再次執(zhí)行:
[root@localhost phpredis]# /usr/bin/phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
執(zhí)行完上一步,我們就有了 configure 配置文件了,接下來配置
[root@localhost phpredis]#./configure
或者執(zhí)行
[root@localhost phpredis]#./configure --with-php-config=/usr/bin/php-config
接下來是編譯安裝
[root@localhost phpredis]#make?
[root@localhost phpredis]# make install
?Installing shared extensions:? ? ? /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/
配置php的配置文件php.ini(具體放在那里可以用 whereis php.ini 來查看),我的配置文件php.ini在/etc/下
[root@localhost phpredis]#vim /etc/php.ini
開啟redis擴展:
extension = redis.so
redis.so文件的路徑可以在make install的時候看到
[root@localhost local]# php -m? #查詢php的擴展
重啟nginx服務(wù)器,重啟
service php-fpm restart
service nginx restart
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。