在centos7中為php7安裝redis擴充套件

2022-09-09 21:27:23 字數 2023 閱讀 3851

$ wget

$ tar xzf redis-4.0.6.tar.gz

$ cd redis-4.0.6

$ make && make prefix=/usr/local/redis install #安裝到指定目錄

現在去剛剛tar包解壓出來的原始碼目錄中,拷貝乙個redis.conf配置檔案,放到/usr/local/redis/bin/目錄下

進入到redis目錄下,執行vi redis.conf

將daemonize no改為 daemonize yes儲存退出

通過下面的命令啟動redis服務:

./bin/redis-server ./redis.conf

你可以使用內建的客戶端命令redis-cli進行使用:

$ ./redis-cli

redis> set foo bar

okredis> get foo

"bar"

以上呢是安裝redis程式

在php7中要開啟redis擴充套件

[root@localhost local ]#git clone  

到了這一步,我們要使用安裝php時生成的phpize來生成configure配置檔案,

//具體用哪個要取決於你的phpize檔案所在的目錄,這時你應該用 whereis phpize 來檢視路徑

[root@localhost local ]# whereis phpize

phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz

這裡表明路徑為/usr/bin/phpize,然後執行:

[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所以執行以下命令:

[root@localhost phpredis]#yum -y install php70w-devel

然後再次執行:

[root@localhost phpredis]# /usr/bin/phpize

configuring for:

php api version: 20151012

zend module api no: 20151012

zend extension api no: 320151012

執行完上一步,我們就有了 configure 配置檔案了,接下來配置

[root@localhost phpredis]#./configure

或者執行

[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伺服器,重啟php-fpm,使配置生效

重啟之後我們開啟info.php,已經可以看到redis的擴充套件資訊了

CentOS 7 編譯安裝 PHP 7

使用編譯的方式來安裝 php 7。輸入yum y install libxml2 libxml2 devel openssl openssl devel curl devel libjpeg devel libpng devel freetype devel libmcrypt devel mhas...

CentOS 7 編譯安裝 PHP 7

使用編譯的方式來安裝 php 7。輸入yum y install libxml2 libxml2 devel openssl openssl devel curl devel libjpeg devel libpng devel freetype devel libmcrypt devel mhas...

Centos7 編譯安裝PHP7

centos7 編譯安裝php7 yum groupinstall development tools 2 安裝依賴包 yum install libxml2 libxml2 devel openssl openssl devel bzip2 bzip2 devel libcurl libcurl ...