php7:给已编译安装版本增加一个编译参数(PHP 7.4.2)

一,查看编译时的参数:

1,命令行:
[lhdop@blog etc]$ /usr/local/soft/php7/bin/php -i | grep configure
Configure Command =>  './configure'  '--prefix=/usr/local/soft/php7' '--with-curl' '--with-freetype' '--enable-gd' '--with-jpeg' 
'--with-gettext' '--with-iconv-dir=/usr/local' '--with-kerberos' '--with-libdir=lib64' '--with-libxml' '--with-mysqli' '--with-openssl'
'--with-pdo-mysql' '--with-pdo-sqlite' '--with-pear' '--with-mhash' '--with-ldap-sasl' '--with-xmlrpc' '--with-xsl' '--with-zlib'
'--enable-fpm' '--enable-bcmath' '--enable-mbregex' '--enable-mbstring' '--enable-opcache' '--enable-pcntl' '--enable-shmop'
'--enable-soap' '--enable-sockets' '--enable-xml' '--with-zip' '--with-config-file-path=/usr/local/soft/php7/etc' '-with-bz2'
'--enable-inline-optimization' '--enable-sysvsem'

 

2,通过安装文件找到安装时:
在php安装目录下:
include/php/main/build-defs.h:
#define CONFIGURE_COMMAND " './configure'  '--prefix=/usr/local/soft/php7' '--with-curl' '--with-freetype' '--enable-gd' 
'--with-jpeg' '--with-gettext' '--with-iconv-dir=/usr/local' '--with-kerberos' '--with-libdir=lib64' '--with-libxml' '--with-mysqli'
'--with-openssl' '--with-pdo-mysql' '--with-pdo-sqlite' '--with-pear' '--with-mhash' '--with-ldap-sasl' '--with-xmlrpc' '--with-xsl'
'--with-zlib' '--enable-fpm' '--enable-bcmath' '--enable-mbregex' '--enable-mbstring' '--enable-opcache' '--enable-pcntl' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-xml' '--with-zip'
'--with-config-file-path=/usr/local/soft/php7/etc' '-with-bz2' '--enable-inline-optimization' '--enable-sysvsem'"

说明:刘宏缔的架构森林是一个专注架构的博客,

网站:https://blog.imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/06/01/php7-gei-yi-bian-yi-an-zhuang-ban-ben-zeng-jia-yi-ge-bian/

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

 

二,增加编译参数

1,在安装时的源码目录或找到相同版本的源码
进入源码目录
[root@blog ~]# cd /usr/local/source/
[root@blog source]# cd php-7.4.2/

clean

[root@blog php-7.4.2]# make clean

重新configure

[root@blog php-7.4.2]# ./configure  --prefix=/usr/local/soft/php7 --with-curl --with-freetype --enable-gd --with-jpeg 
--with-gettext --with-iconv-dir=/usr/local --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl
--with-pdo-mysql --with-pdo-sqlite --with-pear --with-mhash --with-ldap-sasl --with-xmlrpc --with-xsl --with-zlib
--enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap
--enable-sockets --enable-xml --with-zip --with-config-file-path=/usr/local/soft/php7/etc -with-bz2 --enable-inline-optimization
--enable-sysvsem --enable-exif
说明:configure时增加了参数: --enable-exif
安装
[root@blog php-7.4.2]# make && make install   
2,重启php-fpm
[root@blog php-7.4.2]# /usr/local/soft/php7/daemon/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done 
3,查看效果:
未加exif参数前的报错:
Fatal error: Uncaught Error: Call to undefined function exif_read_data() in /web/think_web/think_www/prog_action/test/test_action.php:11 
Stack trace:
#0 /web/think_web/think_www/html/v.php(165): test_action->go()
#1 {main} thrown in /web/think_web/think_www/prog_action/test/test_action.php on line 11
如图:
 
增加参数后:
array(2) { ["FILE"]=> array(6) { ["FileName"]=> string(6) "42.jpg" ["FileDateTime"]=> int(1650439867) ["FileSize"]=> int(1274545) ["FileType"]=> int(2) ["MimeType"]=> string(10) "image/jpeg" ["SectionsFound"]=> string(0) "" } ["COMPUTED"]=> array(4) { ["html"]=> string(26) "width="2880" height="1800"" ["Height"]=> int(1800) ["Width"]=> int(2880) ["IsColor"]=> int(1) } }
获取到的exif数据:

三,查看php的版本:

[lhdop@blog php7]$ /usr/local/soft/php7/bin/php --version
PHP 7.4.2 (cli) (built: Mar  5 2020 11:16:38) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies 

 

posted @ 2022-04-23 21:47  刘宏缔的架构森林  阅读(403)  评论(0编辑  收藏  举报