一,phpize的好处
什么时候我们要用phpize呢?我们在安装php时:
./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模块安装为例子:
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-configmake && make install
安装完后会有这样的东西
See any operating system documentation about shared libraries formore 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
cd /app/product/php5/lib/php/extensions/no-debug-non-zts-20060613/ls -al |grep gd-rwxr-xr-x 1 root root 763334 Feb 9 10:51 gd.sovi /app/product/php5/lib/php.ini在加载模块的地加上一行extension=gd.so
四,重起phpf服务
查看编译的模块:
/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/phpizeCannot 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/phpizeConfiguring for:PHP Api Version: 20151012Zend Module Api No: 20151012Zend 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/grepchecking for egrep... /bin/grep -Echecking for a sed that does not truncate output... /bin/sedchecking for cc... ccchecking for C compiler default output file name... a.outchecking whether the C compiler works... yes......creating libtoolappending configuration tag "CXX" to libtoolconfigure: creating ./config.statusconfig.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