php扩展 模块安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php扩展 模块安装相关的知识,希望对你有一定的参考价值。

php扩展模块安装

技术分享图片

1.首先下载redis包并改名:

[[email protected] 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]

[[email protected] src]# du -sh develop
228K    develop
[[email protected] src]# mv develop phpredis-develop.zip

2.解压缩

[[email protected] src]# unzip phpredis-develop.zip 

3.进入目录,并生成configure文件:

[[email protected] src]# cd phpredis-develop/
[[email protected] 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包:

[[email protected] 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文件:成功

[[email protected] phpredis-develop]# /usr/local/php7/bin/phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[[email protected] 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.进行编译:

[[email protected] 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
[[email protected] 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
[[email protected] phpredis-develop]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
[[email protected] phpredis-develop]# ls  /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
opcache.so  redis.so

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

[[email protected] 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.增加一行配置:

[[email protected] phpredis-develop]#  vim /usr/local/php/etc/php.ini  
extension = redis.so  

9.测试:

[[email protected] phpredis-develop]# /usr/local/php/bin/php -m |grep redis
redis

以上是关于php扩展 模块安装的主要内容,如果未能解决你的问题,请参考以下文章

PHP扩展模块安装

PHP动态扩展模块安装

88.PHP扩展模块安装

php扩展模块安装

PHP 如何安装扩展模块

四十PHP扩展模块安装