使用phpize增加php模块

一,phpize的好处

什么时候我们要用phpize呢?我们在安装php时:

1
2
3
4
5
. / configure  - - prefix = / apps / product / php  - - with - config - file - path = / apps / product / php / etc \
- - with - iconv - dir  - - with - freetype - dir  - - with - png - dir  - - with - zlib  - - with - libxml - dir = / usr  \
- - enable - xml  - - enable - discard - path  - - enable - safe - mode  - - enable - bcmath \
- - enable - shmop  - - enable - sysvsem  - - enable - inline - optimization  - - with - curl \
- - with - curlwrappers  - - enable - mbregex  - - enable - fastcgi  - - enable - fpm \

后面根的参数是我们要的模块,但是随着工作的需要,我们还要在加些模块,又不想重新编译php,这些我们就可以用phpize了。

二,安装php模块

下面我以gd模块安装为例子:

1
2
3
4
5
6
7
8
9
cd  / apps / product / php - 5.6 . 10 / ext / gd                 #ext目录下面放的是php的模块库
 
/ apps / product / php5 / bin / phpize
 
#确定php-config文件是否存在,调用php-config,安装后.so文件会自动放到extension_dir里面
 
. / configure  - - enable - gd  - - with - php - config = / apps / product / php5 / bin / php - config
 
make && make install

安装完后会有这样的东西

1
2
3
4
5
6
7
8
See  any  operating system documentation about shared libraries  for
more information, such as the ld( 1 and  ld.so( 8 ) manual pages.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Build complete.
Don 't forget to run ' make test'.
 
Installing shared extensions:      / app / product / php5 / lib / php / extensions / no - debug - non - zts - 20060613 /

三,查看.so文件,以及修改php.ini

1
2
3
4
5
6
7
8
9
cd   / app / product / php5 / lib / php / extensions / no - debug - non - zts - 20060613 /
 
ls  - al |grep gd
 
- rwxr - xr - 1  root  root    763334  Feb   9  10 : 51  gd.so
 
vi   / app / product / php5 / lib / php.ini
 
在加载模块的地加上一行extension = gd.so

四,重起phpf服务

查看编译的模块:

1
2
3
/ apps / product / php5 / bin / php  - i|grep configure
 
/ apps / product / php5 / bin / php  - m 

php 开启openssl扩展:(当时没测试成功,只能重新编译安装了)

复制代码
#进入源码目录:

cd /usr/local/src/php-7.0.14/ext/openssl

[root@supplier-pre01 openssl]# /usr/local/php7/bin/phpize
Cannot find config.m4. 
Make sure that you run '/usr/local/php7/bin/phpize' in the top level source directory of the module

[root@supplier-pre01 openssl]# 

[root@supplier-pre01 openssl]# mv config0.m4 config.m4

[root@supplier-pre01 openssl]# /usr/local/php7/bin/phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
[root@supplier-pre01 openssl]# 
[root@supplier-pre01 openssl]# ./configure --with-openssl --with-php-config=/usr/local/php7/bin/php-config  
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
......
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h

[root@supplier-pre01 openssl]# make && make install

----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/


执行安装后,会提示在某个目录生成.so文件,我生成的位置在/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
打开php.ini,添加下面两句话.

vim /usr/local/php7/etc/php.ini 
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/"  
extension=openssl.so
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值