LAMP-php动态扩展模块安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP-php动态扩展模块安装相关的知识,希望对你有一定的参考价值。
在php编译完成后,如果想增加一个功能模块,要么重新编译php,要么直接编译一个扩展模块。重新编译php会影响现网中的业务,因此直接编译扩展模块更好些。
[[email protected] ~]# /usr/local/php/bin/php -m ##查看php加载的功能模块
下面演示安装redis扩展模块:
1、下载安装包
[[email protected] ~]# cd /usr/local/src [[email protected] src]# wget https://codeload.github.com/phpredis/phpredis/zip/develop --2017-07-22 01:30:22-- 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 长度:221385 (216K) [application/zip] 正在保存至: “develop” 100%[=====================================================================================================================================================>] 221,385 36.6KB/s 用时 5.9s 2017-07-22 01:30:30 (36.6 KB/s) - 已保存 “develop” [221385/221385])
2、解压压缩包
[[email protected] src]# mv develop phpredis-develop.zip [[email protected] src]# unzip phpredis-develop.zip
3、生成configure文件
[[email protected] src]# cd phpredis-develop [[email protected] phpredis-develop]# /usr/local/php/bin/ph phar phar.phar php php-cgi php-config phpize [[email protected] phpredis-develop]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
报错,安装autoconf后,再次执行。
[[email protected] phpredis-develop]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226
4、加载配置
[[email protected] phpredis-develop]# ./configure --with-php-config=/usr/local/php/bin/php-config checking 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 ...... creating libtool appending configuration tag "CXX" to libtool configure: creating ./config.status config.status: creating config.h [[email protected] phpredis-develop]# echo $? 0
5、编译与编译安装
[[email protected] phpredis-develop]# make &&make install [[email protected] phpredis-develop]# echo $? 0
6、编辑php配置
[[email protected] phpredis-develop]# /usr/local/php/bin/php -i | grep extension_dir 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 [[email protected] phpredis-develop]# ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226 opcache.so redis.so [[email protected] phpredis-develop]# vi /usr/local/php/etc/php.ini extension = redis.so ##增加一行
7、检查效果
[[email protected] phpredis-develop]# /usr/local/php/bin/php -m |grep redis redis
如果想在php网站使用redis模块,需要重启httpd服务。
本文出自 “Gorilla Grodd” 博客,请务必保留此出处http://juispan.blog.51cto.com/943137/1953716
以上是关于LAMP-php动态扩展模块安装的主要内容,如果未能解决你的问题,请参考以下文章