一,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-config make && make install
安裝完后會有這樣的東西
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
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.so vi /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/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