目录
php扩展模块安装
php扩展模块安装
PHP一旦编译完成后,要想再增加一个功能模块的话,要么重新编译PHP,要么直接编译一个扩展模块(生成一个.so文件),然后在php.ini中配置一下,就可以被加载使用了。
查看PHP都加载的功能模块
[root@minglinux-01 ~] /usr/local/php/bin/php -m
PHP Deprecated: Comments starting with '#' are deprecated in /usr/local/php/etc/php.ini on line 450 in Unknown on line 0
[PHP Modules]
bz2
Core
ctype
date
dom
ereg
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
- 以扩展模块的形式编译安装一个PHP的redis模块
[root@minglinux-01 /usr/local/src] wget https://codeload.github.com/phpredis/phpredis/zip/develop
[root@minglinux-01 /usr/local/src] mv develop phpredis-develop.zip
[root@minglinux-01 /usr/local/src] unzip phpredis-develop.zip
[root@minglinux-01 /usr/local/src] cd phpredis-develop/
[root@minglinux-01 /usr/local/src/phpredis-develop] /usr/local/php/bin/phpize //目的是生成configure文件,没有就无法编译
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包,所以先安装该包再生成一次
[root@minglinux-01 /usr/local/src/phpredis-develop] yum install -y autoconf
[root@minglinux-01 /usr/local/src/phpredis-develop] /usr/local/php/bin/phpize //再执行一次
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[root@minglinux-01 /usr/local/src/phpredis-develop] ll |grep configure //生成了configure文件
-rwxr-xr-x 1 root root 451368 11月 21 22:04 configure
-rw-r--r-- 1 root root 4690 11月 21 22:04 configure.in
[root@minglinux-01 /usr/local/src/phpredis-develop] ./configure --with-php-config=/usr/local/php/bin/php-config //生成可编译文件
[root@minglinux-01 /usr/local/src/phpredis-develop] make
[root@minglinux-01 /usr/local/src/phpredis-develop] make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
// make install的时候会把编译好的redis.so放到这个目录下面,这个目录也是扩展模块存放目录
[root@minglinux-01 /usr/local/src/phpredis-develop] ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
opcache.so redis.so
[root@minglinux-01 /usr/local/src/phpredis-develop] /usr/local/php/bin/php -i |grep extension_dir //可以在php.in自定义该路径
PHP Deprecated: Comments starting with '#' are deprecated in /usr/local/php/etc/php.ini on line 450 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
[root@minglinux-01 /usr/local/src/phpredis-develop] /usr/local/php7/bin/php -m|grep redis //未加载redis模块
-bash: /usr/local/php/bin/php: 没有那个文件或目录
[root@minglinux-01 /usr/local/src/phpredis-develop] vim /usr/local/php/etc/php.ini
extension = redis.so //在php.in中添加这一行
[root@minglinux-01 /usr/local/src/phpredis-develop] /usr/local/php/bin/php -m|grep redis
PHP Deprecated: Comments starting with '#' are deprecated in /usr/local/php/etc/php.ini on line 450 in Unknown on line 0
redis //已经加载了redis模块
redis等模块不是php自带,使用时需要专门下载。在php源码包中的ext目录下有很多模块,该目录下的模块安装配置不需要下载,只要进入对应包的目录,执行/usr/local/php/bin/phpize在该目录下生成configure文件,然后生成可编译文件,编译、安装即可。生成可编译文件(即执行./configure)时需要跟参数--with-php-config=/usr/local/php/bin/php-config。
[root@minglinux-01 /usr/local/src/php-5.6.30] pwd
/usr/local/src/php-5.6.30
[root@minglinux-01 /usr/local/src/php-5.6.30] ls ext/
bcmath ftp mysqli pgsql standard
bz2 gd mysqlnd phar sybase_ct
calendar gettext oci8 posix sysvmsg
com_dotnet gmp odbc pspell sysvsem
ctype hash opcache readline sysvshm
curl iconv openssl recode tidy
date imap pcntl reflection tokenizer
dba interbase pcre session wddx
dom intl pdo shmop xml
enchant json pdo_dblib simplexml xmlreader
ereg ldap pdo_firebird skeleton xmlrpc
exif libxml pdo_mysql snmp xmlwriter
ext_skel mbstring pdo_oci soap xsl
ext_skel_win32.php mcrypt pdo_odbc sockets zip
fileinfo mssql pdo_pgsql spl zlib
filter mysql pdo_sqlite sqlite3
扩展
apache rewrite教程 http://coffeelet.blog.163.com/blog/static/13515745320115842755199/ http://www.cnblogs.com/top5/archive/2009/08/12/1544098.html
apache rewrite 出现死循环 http://ask.apelearn.com/question/1043
php错误日志级别参考 http://ask.apelearn.com/question/6973
php开启短标签 http://ask.apelearn.com/question/120
php.ini详解 http://legolas.blog.51cto.com/2682485/493917