標籤: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/phphar phar.phar php php-cgi php-config phpize [[email protected] phpredis-develop]# /usr/local/php/bin/phpize Configuring for:PHP Api Version: 20131106Zend Module Api No: 20131226Zend Extension Api No: 220131226Cannot 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: 20131106Zend Module Api No: 20131226Zend Extension Api No: 220131226
4、載入配置
[[email protected] phpredis-develop]# ./configure --with-php-config=/usr/local/php/bin/php-configchecking for grep that handles long lines and -e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking for a sed that does not truncate output... /usr/bin/sedchecking for cc... ccchecking whether the C compiler works... yes......creating libtoolappending configuration tag "CXX" to libtoolconfigure: creating ./config.statusconfig.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_dirextension_dir => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 => /usr/local/php/lib/php/extensions/no-debug-zts-20131226sqlite3.extension_dir => no value => no value[[email protected] phpredis-develop]# ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226opcache.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 redisredis
如果想在php網站使用redis模組,需要重啟httpd服務。
本文出自 “Gorilla Grodd” 部落格,請務必保留此出處http://juispan.blog.51cto.com/943137/1953716
LAMP-php動態擴充模組安裝