PHP 编译参数相关说明

2019-01-05 2249点热度 3人点赞

PHP 有很多编译参数 ,本文将记录这些编译参数和相关联的组件


PHP 7.4.0

以下编译参数需要的相关 RPM 包安装命令

yum install -y gcc gcc-c++ make libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel libwebp-devel freetype-devel sqlite-devel oniguruma-devel bison autoconf
rpm -ivh http://packages.psychotic.ninja/7/plus/x86_64/RPMS//libzip-0.11.2-6.el7.psychotic.x86_64.rpm
rpm -ivh http://packages.psychotic.ninja/7/plus/x86_64/RPMS//libzip-devel-0.11.2-6.el7.psychotic.x86_64.rpm

完整编译参数

./configure --prefix=/usr/local/php74 --exec-prefix=/usr/local/php74 --bindir=/usr/local/php74/bin --sbindir=/usr/local/php74/sbin --includedir=/usr/local/php74/include --libdir=/usr/local/php74/lib/php --mandir=/usr/local/php74/php/man --with-config-file-path=/usr/local/php74/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --enable-gd --with-iconv --with-zlib --with-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg --with-webp --with-freetype --enable-opcache --enable-fpm --disable-cgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo

下面是在 PHP7.4 有变动的参数

--with-gd
[7.4 已替换][使用 --enable-gd 作为新的参数]
[https://www.php.net/manual/zh/image.installation.php#124600]
--enable-zip --with-libzip
[7.4 已替换][使用 --with-zip 作为新的参数]
[https://www.php.net/manual/zh/zip.installation.php]
[从 PHP 7.4.0 开始,必须在编译 PHP 时用 --with-zip 配置选项来提供 zip 支持。之前的 PHP 版本,需要使用 --enable-zip 选项。]
--with-jpeg-dir
[7.4 已替换][使用 --with-jpeg 作为新的参数]
[https://www.php.net/manual/en/image.installation.php]
[要启用对 jpeg 的支持,请添加 --with-jpeg-dir=DIR 。支持 Jpeg 6b 、 7 或 8 。从 PHP 7.4.0 开始,使用 --with-jpeg 来代替。]
--with-png-dir
[7.4 已移除]
[https://www.php.net/manual/en/image.installation.php]
[要启用对 png 的支持,请添加 --with-png-dir=DIR 。注意,libpng 需要 zlib 库,因此在配置行中添加 --with-zlib-dir[=DIR] 。从 PHP 7.4.0 开始,--with-png-dir 和 --with-zlib-dir 已经被删除,libpng 和 zlib 是必需的。]
--with-webp-dir
[7.4 已替换][使用 --with-webp 作为新的参数]
[https://www.php.net/manual/en/image.installation.php]
[要启用对 webp 的支持,添加 --with-webp-dir=DIR 。从 PHP 7.4.0 开始,使用 --with-webp 来代替。]
--with-freetype-dir
[7.4 已替换][使用 --with-freetype 作为新的参数]
[https://www.php.net/manual/en/image.installation.php]
[要启用对 FreeType 2 的支持,添加 --with-freetype-dir=DIR 。在 PHP 7.4.0 中,使用 --with-freetype 来代替,它依赖于 pkg-config 。]

PHP 7.3.0

以下编译参数需要的相关 RPM 包安装命令

yum install -y gcc gcc-c++ make libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel bison autoconf
rpm -ivh http://packages.psychotic.ninja/7/plus/x86_64/RPMS//libzip-0.11.2-6.el7.psychotic.x86_64.rpm
rpm -ivh http://packages.psychotic.ninja/7/plus/x86_64/RPMS//libzip-devel-0.11.2-6.el7.psychotic.x86_64.rpm

完整编译参数

./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv  --with-zlib --with-libzip --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-png-dir--with-freetype-dir --enable-opcache --enable-fpm --disable-cgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo
[root@localhost php-build]# ./configure \
--prefix=/usr/local/php7 \                              [php 安装的根目录]
--exec-prefix=/usr/local/php7 \                         [php 执行文件所在目录]
--bindir=/usr/local/php7/bin \                          [php/bin 目录]
--sbindir=/usr/local/php7/sbin \                        [php/sbin 目录]
--includedir=/usr/local/php7/include \                  [php 包含文件所在目录]
--libdir=/usr/local/php7/lib/php \                      [php/lib 目录]
--mandir=/usr/local/php7/php/man \                      [php/man 目录]
--with-config-file-path=/usr/local/php7/etc \           [php 的配置目录]
--with-mysql-sock=/var/run/mysql/mysql.sock \           [php 与 mysql 的 Unix socket 通信文件]
--with-mhash \                                          [Mhash 是基于离散数学原理的不可逆向的 php 加密方式扩展库,其在默认情况下不开启]
--with-openssl \                                        [OpenSSL 是一个安全套接字层密码库]
--with-mysqli=shared,mysqlnd \                          [php 依赖 mysqli 库]
--with-pdo-mysql=shared,mysqlnd \                       [php 依赖 pdo-mysql 库]
--with-gd \                                             [gd 库]                                               
--with-iconv \                                          [关闭 iconv 函数,种字符集间的转换]                        
--with-zlib \                                           [zlib 是提供数据压缩用的函式库]
--enable-zip \                                          [打开对 zip 的支持]
--enable-inline-optimization \                          [优化线程]
--disable-debug \                                       [关闭调试模式]
--disable-rpath \                                       [关闭额外的运行库文件]
--enable-shared \                                       [启用动态库]
--enable-xml \                                          [开启 xml 扩展]
--enable-bcmath \                                       [打开图片大小调整, 用到 zabbix 监控的时候用到了这个模块]
--enable-shmop \                                        [共享内存]
--enable-sysvsem \                                      [共享内存方案]
--enable-sysvshm \                                      [信号量方案]
--enable-sysvmsg \                                      [进程间通信方案]
--enable-mbregex \                                      [开启多字节正则表达式的字符编码。]
--enable-mbstring \                                     [开启多字节字符串函数]
--enable-ftp \                                          [开启 ftp]
--enable-pcntl \                                        [PHP 的进程控制支持实现了 Unix 方式的多进程创建]     
--enable-sockets \                                      [开启套节字]
--with-xmlrpc \                                         [打开 xml-rpc 的 c 语言]
--enable-soap \                                         [开启简单对象访问协议简单对象访问协议]
--without-pear \                                        [开启 php 扩展与应用库]
--with-gettext \                                        [开户 php 在当前域中查找消息]
--enable-session \                                      [允许 php 会话 session]
--with-curl \                                           [允许 curl 扩展]
--with-jpeg-dir \                                       [指定 jpeg 安装目录 yum 安装过后不用再次指定会自动找到]
--with-png-dir \                                        [指定 jpeg 安装目录 yum 安装过后不用再次指定会自动找到]
--with-freetype-dir \                                   [指定 freetype 安装目录 yum 安装过后不用再次指定会自动找到]
--enable-opcache \                                      [开启使用 opcache 缓存]
--enable-fpm \                                          [开启 fpm]
--disable-cgi \                                         [关闭 php-cgi]
--with-fpm-user=nginx \                                 [php-fpm 的用户]
--with-fpm-group=nginx \                                [php-fpm 的用户组]
--without-gdbm \                                        [数据库函数使用可扩展散列和类似于标准 UNIX dbm 的工作]
--enable-fast-install \                                 [为快速安装优化]
--disable-fileinfo                                      [解决不足 1GB 内存的机器出现内存不足]

下面还有一些参数,就不是很常见需要的了

--enable-fastcgi \                                      [开启 FastCGI 关联 Apache]
--with-bz2 \                                            [对 bz2 文件的支持]
--with-libxml-dir \                                     [对 libxml2 库的支持]
--enable-gd-jis-conv \                                  [启用 GD 库的 JIS 日文字体支持]
--with-readline \                                       [PHP 的 CLI 模式信息交互模块]

下面是在 PHP7.3 有变动的参数

--with-zlib
[7.3 已变动]
[7.2 会出现警告,内容如下]
configure: WARNING: ========================================================
configure: WARNING: Use of bundled libzip is deprecated and will be removed.
configure: WARNING: Some features such as encryption and bzip2 are not available.
configure: WARNING: Use system library and --with-libzip is recommended.
configure: WARNING: ========================================================
[PHP 将额外调用 libzip 0.11 的模块]
configure: error: system libzip must be upgraded to version >= 0.11
--with-mcrypt
[7.2 已停用][官方建議使用 Sodium 或 OpenSSL 取代][http://php.net/manual/en/intro.mcrypt.php]
[是 php 里面重要的加密支持扩展库,linux 环境下该库在默认情况下不开启]
--with-mysql
[7.2 已停用][已被 mysqli 完全替换]
[php 依赖 mysql 库]
--enable-gd-native-ttf
[7.2 已停用][已被 GD 移除此选项]
[开启 gd 库原有字体]

PHP 5.6.30

以下编译参数需要的相关 RPM 包安装命令

yum install -y libmcrypt libmcrypt-devel libjpeg-devel libpng libpng-devel libxml2-devel freetype-devel glib2-devel bzip2-devel openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel

完整编译参数

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysql --with-mysqli --with-pdo-mysql --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --disable-fileinfo

StarryVoid

Have a good time