peixiguang

php如何添加扩展

系统debian

1,查看系统php

wheris php  --这是系统自带的php

root@debian:/etc/php5/fpm# whereis php
php: /usr/bin/php /usr/bin/X11/php /usr/share/php /usr/share/man/man1/php.1.gz

whereis php5 --这是通过apt-get install 安装的lnmp 环境

root@debian:/etc/php5/fpm# whereis php5
php5: /usr/bin/php5 /etc/php5 /usr/lib/php5 /usr/bin/X11/php5 /usr/include/php5 /usr/share/php5 /usr/share/man/man1/php5.1.gz

 whereis phpize   --如果没有这个扩展 需要安装apt-get install php5-dev

root@debian:/etc/php5/fpm# whereis phpize
phpize: /usr/bin/phpize /usr/bin/X11/phpize /usr/share/man/man1/phpize.1.gz

 2,找到php5扩展文件夹下--ext_skel

root@debian:/usr/include/php5/ext# ls
date  ereg      filter  hash   json    mbstring  pcre  pxg      sockets  standard
dom   ext_skel  gd      iconv  libxml  mysqli    pdo   session  spl      xml
root@debian:/usr/include/php5/ext# 

 生成扩展框架

./ext_skel --extanme=pxg  可能会报错

cannot open /skeleton.c: No such file

查看help

whereis php5 找到skeleton路径

/usr/include/php5/skeleton

删除刚才生成的扩展文件重新生成扩展 

./ext_skel --extname=pxg --skel=/usr/include/php5/skeleton

成功生成扩展文件框架

3,编译扩展

cd pxg
vim config.m4
把下面去掉
dnl PHP_ARG_ENABLE(xw, whether to enable xw support,
dnl Make sure that the comment is aligned:
dnl [  --enable-xw           Enable xw support])

修改成

 PHP_ARG_ENABLE(xw, whether to enable xw support,
 Make sure that the comment is aligned:
 [  --enable-xw           Enable xw support])

依次执行

phpize
./configure
make
make instll 

如果成功则显示

Installing shared extensions:     /usr/lib/php5/20100525/

在里面可以找到pxg.so

找到php.ini添加extension=pxg.so

重启nginx php 

php5-fpm -m
 

就可以看到php添加了pxg 扩展

分类:

技术点:

相关文章: