1. 程式人生 > >php擴展 模塊安裝

php擴展 模塊安裝

redis

php擴展模塊安裝

技術分享圖片

1.首先下載redis包並改名:

[root@weixing01 src]# wget https://codeload.github.com/phpredis/phpredis/zip/develop
--2018-03-08 20:56:11--  https://codeload.github.com/phpredis/phpredis/zip/develop
正在解析主機 codeload.github.com (codeload.github.com)... 192.30.255.120, 192.30.255.121
正在連接 codeload.github.com (codeload.github.com)|192.30.255.120|:443... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:未指定 [application/zip]
正在保存至: “develop”

    [       <=>                                           ] 230,093      105KB/s 用時 2.1s   

2018-03-08 20:56:15 (105 KB/s) - “develop” 已保存 [230093]

[root@weixing01 src]# du -sh develop
228K    develop
[root@weixing01 src]# mv develop phpredis-develop.zip

2.解壓縮

[root@weixing01 src]# unzip phpredis-develop.zip 

3.進入目錄,並生成configure文件:

[root@weixing01 src]# cd phpredis-develop/
[root@weixing01 phpredis-develop]# /usr/local/php7/bin/phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

報錯,缺少一個包

4.安裝autoconf包:

[root@weixing01 phpredis-develop]# yum install -y autoconf
已加載插件:fastestmirror
base                                                                   | 3.6 kB  00:00:00     
epel/x86_64/metalink                                                   | 6.7 kB  00:00:00     
epel                                                                   | 4.7 kB  00:00:00     
extras                                                                 | 3.4 kB  00:00:00     
updates                                                                | 3.4 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                     

5.再次生成configure文件:成功

[root@weixing01 phpredis-develop]# /usr/local/php7/bin/phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[root@weixing01 phpredis-develop]# ls
acinclude.m4       config.h.in   debian.control     mkdeb.sh            redis_cluster.c
aclocal.m4         config.m4     install-sh         mkinstalldirs       redis_cluster.h
arrays.markdown    config.sub    ISSUE_TEMPLATE.md  package.xml         redis_commands.c
autom4te.cache     configure     liblzf             php_redis.h         redis_commands.h
build              configure.in  library.c          README.markdown     redis_session.c
cluster_library.c  config.w32    library.h          redis_array.c       redis_session.h
cluster_library.h  COPYING       ltmain.sh          redis_array.h       rpm
cluster.markdown   crc16.h       Makefile.global    redis_array_impl.c  run-tests.php
common.h           CREDITS       missing            redis_array_impl.h  serialize.list
config.guess       debian        mkdeb-apache2.sh   redis.c             tests

6.進行編譯:

[root@weixing01 phpredis-develop]# ./configure --with-php-config=/usr/local/php/bin/php-configchecking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
[root@weixing01 phpredis-develop]# make
/bin/sh /usr/local/src/phpredis-develop/libtool --mode=compile cc  -I. -I/usr/local/src/phpredis-develop -DPHP_ATOM_INC -I/usr/local/src/phpredis-develop/include -I/usr/local/src/phpredis-develop/main -I/usr/local/src/phpredis-develop -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/phpredis-develop/redis.c -o redis.lo 
mkdir .libs
[root@weixing01 phpredis-develop]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
[root@weixing01 phpredis-develop]# ls  /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
opcache.so  redis.so

7.查看配置文件存放位置:

[root@weixing01 phpredis-develop]# /usr/local/php/bin/php -i |grep -i extension_dir
PHP Warning:  Unknown: It is not safe to rely on the system‘s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC‘ for now, but please set date.timezone to select your timezone. in Unknown on line 0
extension_dir => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 => /usr/local/php/lib/php/extensions/no-debug-zts-20131226
sqlite3.extension_dir => no value => no value

8.增加一行配置:

[root@weixing01 phpredis-develop]#  vim /usr/local/php/etc/php.ini  
extension = redis.so  

9.測試:

[root@weixing01 phpredis-develop]# /usr/local/php/bin/php -m |grep redis
redis

php擴展 模塊安裝