PHP 5.4 编译参数

本文主要整理了 PHP 5.4 的编译参数,并对一些参数和第三方扩展做以说明

截止到目前 2016-06-23 PHP 5.4 的兼容性还是最好的。

编译参数(Nginx + PHP-FPM)

./configure --prefix=/usr/local/server/php \
--with-config-file-path=/usr/local/server/php/etc \
--with-libdir=lib \
--enable-fpm \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-mysqlnd \
--enable-wddx \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-exif \
--enable-soap \
--with-iconv-dir \
--with-zlib \
--with-bz2 \
--with-openssl \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-t1lib \
--with-mhash \
--with-mcrypt \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-xsl \
--with-libedit \
--with-snmp \
--with-tidy \
--with-xmlrpc \
--with-libxml-dir

PECL 常用扩展

  • ZendOpcache

http://pecl.php.net/package/ZendOpcache (PHP 5.5+ 已经内置)

  • Redis 2.2.7

http://pecl.php.net/package/redis (2.2.8支持Cluster特性,3.0开始支持PHP 7)

  • Mongo

http://pecl.php.net/package/mongo (目前只支持到Mongo 3.0,2016-06-13)
http://pecl.php.net/package/mongodb (支持 Mongo3.2 以及 PHP 7)

  • Solr

http://pecl.php.net/package/solr (已支持PHP7)

  • Swoole

http://pecl.php.net/package/swoole (已支持PHP7)

http://pecl.php.net/package/memcache (不支持 PHP 7,2016-06-13)

  • rar

http://pecl.php.net/package/rar (不支持 PHP 7,2016-06-13)

  • inotify

http://pecl.php.net/package/inotify (已支持PHP 7)

  • pdf

http://pecl.php.net/package/pdflib (不支持 PHP 7,2016-06-13)

  • YAML

http://pecl.php.net/package/yaml (2.0以后版本支持PHP 7)

  • Taint

http://pecl.php.net/package/taint (已支持 PHP 7)

  • Gearman

http://pecl.php.net/package/gearman (不支持 PHP 7,2016-06-13)

  • Sphinx

http://pecl.php.net/package/sphinx (不支持 PHP 7,2016-06-13)

  • OAuth

http://pecl.php.net/package/oauth (2.0开始支持PHP 7)

全局配置

--with-config-file-path=PATH
--with-config-file-scan-dir=PATH
--with-libdir=NAME      Look for libraries in .../NAME rather than .../lib

编译参数说明

内置未开启扩展

默认未开启,但常用的扩展,推荐开启:

--enable-fpm            Enable building of the fpm SAPI executable
--enable-bcmath         Enable bc style precision math functions
--enable-calendar       Enable support for calendar conversion
--enable-ftp            Enable FTP support
--enable-gd-native-ttf  GD: Enable TrueType string function
--enable-mbstring       Enable multibyte string support
--enable-pcntl          Enable pcntl support (CLI/CGI only)
--enable-sockets        Enable sockets support
--enable-zip            Include Zip read/write support
--enable-mysqlnd        Enable mysqlnd explicitly, will be done implicitly

默认未开启,可能会用到的扩展,选择性开启:

--enable-wddx           Enable WDDX support
--enable-exif           Enable EXIF (metadata from images) support
--enable-soap           Enable SOAP support
--enable-shmop          Enable shmop support
--enable-sysvmsg        Enable sysvmsg support
--enable-sysvsem        Enable System V semaphore support
--enable-sysvshm        Enable the System V shared memory support

默认未开启的其他内置扩展:

--enable-zend-signals   Use zend signal handling
--enable-maintainer-zts Enable thread safety - for code maintainers only!!
--enable-debug          Compile with debugging symbols
--enable-sigchild       Enable PHP's own SIGCHLD handler
--enable-gd-jis-conv      GD: Enable JIS-mapped Japanese font support
--enable-embedded-mysqli  MYSQLi: Enable embedded support

内置开启可以关闭的扩展

默认开启,不常用的扩展,可以关闭:

--disable-rpath         Disable passing additional runtime library
--disable-cgi           Disable building CGI version of PHP
--disable-mysqlnd-compression-support
--disable-inifile       DBA: INI support (bundled)
--disable-flatfile      DBA: FlatFile support (bundled)

默认开启,不建议关闭的扩展:

--disable-ipv6          Disable IPv6 support
--disable-filter        Disable input filter support
--disable-tokenizer     Disable tokenizer support
--disable-fileinfo      Disable fileinfo support
--disable-cli           Disable building CLI version of PHP
--disable-libxml        Disable LIBXML support
--disable-ctype         Disable ctype functions
--disable-short-tags    Disable the short-form <? start tag by default
--disable-dom           Disable DOM support
--disable-pdo           Disable PHP Data Objects support
--disable-xml           Disable XML support
--disable-xmlreader     Disable XMLReader support
--disable-xmlwriter     Disable XMLWriter support
--disable-inline-optimization
--disable-hash          Disable hash support
--disable-json          Disable JavaScript Object Serialization support
--disable-phar          Disable phar support
--disable-posix         Disable POSIX-like functions
--disable-session       Disable session support
--disable-simplexml     Disable SimpleXML support
--disable-libtool-lock  avoid locking (might break parallel builds)
--disable-mbregex         MBSTRING: Disable multibyte regex support
--disable-mbregex-backtrack

依赖扩展

需要一些依赖关系的扩展,一般需要先安装一些lib,选择性安装的扩展:

--with-iconv-dir=DIR      XMLRPC-EPI: iconv dir for XMLRPC-EPI

--with-zlib=DIR       Include ZLIB support (requires zlib >= 1.0.9)
--with-zlib-dir=<DIR>   Define the location of zlib install directory
--with-bz2=DIR        Include BZip2 support

--with-openssl=DIR    Include OpenSSL support (requires OpenSSL >= 0.9.6)
--with-openssl-dir=DIR  FTP: openssl install prefix
--with-curl=DIR       Include cURL support
--with-imap=DIR       Include IMAP support. DIR is the c-client install prefix
--with-imap-ssl=DIR     IMAP: Include SSL support. DIR is the OpenSSL install prefix

--with-gd=DIR         Include GD support.  DIR is the GD library base
--with-jpeg-dir=DIR     GD: Set the path to libjpeg install prefix
--with-png-dir=DIR      GD: Set the path to libpng install prefix
--with-zlib-dir=DIR     GD: Set the path to libz install prefix
--with-freetype-dir=DIR GD: Set the path to FreeType 2 install prefix
--with-t1lib=DIR        GD: Include T1lib support. T1lib version >= 5.0.0 required

--with-mhash=DIR      Include mhash support
--with-mcrypt=DIR     Include mcrypt support
--with-kerberos=DIR     OPENSSL: Include Kerberos support

--with-mysql=DIR      Include MySQL support.  DIR is the MySQL base
--with-mysqli=FILE    Include MySQLi support.  FILE is the path
--with-pdo-mysql=DIR    PDO: MySQL support. DIR is the MySQL base directory
--with-mssql=DIR      Include MSSQL-DB support.  DIR is the FreeTDS home
--with-oci8=DIR       Include Oracle Database OCI8 support. DIR defaults to \$ORACLE_HOME.
--with-pdo-oci=DIR      PDO: Oracle OCI support. DIR defaults to \$ORACLE_HOME.

--with-xsl=DIR        Include XSL support.  DIR is the libxslt base
--with-libedit=DIR   Include readline support (CLI/CGI only)
--with-ldap=DIR       Include LDAP support
--with-ldap-sasl=DIR    LDAP: Include Cyrus SASL support
--with-snmp=DIR       Include SNMP support
--with-tidy=DIR       Include TIDY support
--with-xmlrpc=DIR     Include XMLRPC-EPI support
--with-libxml-dir=DIR   LIBXML: libxml2 install prefix
--with-aolserver=DIR    Specify path to the installed AOLserver
--with-apxs2filter=FILE
--with-apxs2=FILE     Build shared Apache 2.0 Handler module. FILE is the optional
--with-apache-hooks=FILE
--with-apache-hooks-static=DIR
--with-caudium=DIR    Build PHP as a Pike module for use with Caudium.
--with-continuity=DIR   Build PHP as Continuity Server module.
--with-fpm-user=USER  Set the user for php-fpm to run as. (default: nobody)
--with-fpm-group=GRP  Set the group for php-fpm to run as. For a system user, this
--with-fpm-systemd      Activate systemd integration
--with-isapi=DIR      Build PHP as an ISAPI module for use with Zeus
--with-litespeed        Build PHP as litespeed module
--with-milter=DIR     Build PHP as Milter application
--with-nsapi=DIR        Build PHP as NSAPI module for Netscape/iPlanet/Sun Webserver
--with-phttpd=DIR       Build PHP as phttpd module
--with-pi3web=DIR     Build PHP as Pi3Web module
--with-roxen=DIR        Build PHP as a Pike module. DIR is the base Roxen
--with-thttpd=SRCDIR    Build PHP as thttpd module
--with-tux=MODULEDIR    Build PHP as a TUX module (Linux only)
--with-webjames=SRCDIR  Build PHP as a WebJames module (RISC OS only)
--with-layout=TYPE      Set how installed files will be laid out.  Type can
--with-regex=TYPE       regex library type: system, php. TYPE=php
--without-sqlite3=DIR Do not include SQLite3 support. DIR is the prefix to
--with-qdbm=DIR         DBA: QDBM support
--with-gdbm=DIR         DBA: GDBM support
--with-ndbm=DIR         DBA: NDBM support
--with-db4=DIR          DBA: Oracle Berkeley DB 4.x or 5.x support
--with-db3=DIR          DBA: Oracle Berkeley DB 3.x support
--with-db2=DIR          DBA: Oracle Berkeley DB 2.x support
--with-db1=DIR          DBA: Oracle Berkeley DB 1.x support/emulation
--with-dbm=DIR          DBA: DBM support
--with-tcadb=DIR        DBA: Tokyo Cabinet abstract DB support
--without-cdb=DIR       DBA: CDB support (bundled)
--with-enchant=DIR     Include enchant support.
--with-vpx-dir=DIR     GD: Set the path to libvpx install prefix
--with-xpm-dir=DIR      GD: Set the path to libXpm install prefix
--with-gettext=DIR    Include GNU gettext support
--with-gmp=DIR        Include GNU MP support
--with-interbase=DIR  Include InterBase support.  DIR is the InterBase base
--with-icu-dir=DIR      Specify where ICU libraries and headers can be found
--with-libmbfl=DIR      MBSTRING: Use external libmbfl.  DIR is the libmbfl base
--with-onig=DIR         MBSTRING: Use external oniguruma. DIR is the oniguruma install
--with-mysql-sock=SOCKPATH   MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
--with-adabas=DIR     Include Adabas D support /usr/local
--with-sapdb=DIR      Include SAP DB support /usr/local
--with-solid=DIR      Include Solid support /usr/local/solid
--with-ibm-db2=DIR    Include IBM DB2 support /home/db2inst1/sqllib
--with-ODBCRouter=DIR Include ODBCRouter.com support /usr
--with-empress=DIR    Include Empress support \$EMPRESSPATH
--with-empress-bcs=DIR
--with-birdstep=DIR   Include Birdstep support /usr/local/birdstep
--with-custom-odbc=DIR
--with-iodbc=DIR      Include iODBC support /usr/local
--with-esoob=DIR      Include Easysoft OOB support /usr/local/easysoft/oob/client
--with-unixODBC=DIR   Include unixODBC support /usr/local
--with-dbmaker=DIR    Include DBMaker support
--with-pdo-dblib=DIR    PDO: DBLIB-DB support.  DIR is the FreeTDS home directory
--with-pdo-firebird=DIR PDO: Firebird support.  DIR is the Firebird base
--with-pdo-odbc=flavour,dir
--with-pdo-pgsql=DIR    PDO: PostgreSQL support.  DIR is the PostgreSQL base
--without-pdo-sqlite=DIR
--with-pgsql=DIR      Include PostgreSQL support.  DIR is the PostgreSQL
--with-pspell=DIR     Include PSPELL support.
--with-libedit=DIR    Include libedit readline replacement (CLI/CGI only)
--with-recode=DIR     Include recode support
--with-mm=DIR           SESSION: Include mm support for session storage
--with-sybase-ct=DIR  Include Sybase-CT support.  DIR is the Sybase home
--with-pear=DIR         Install PEAR in DIR [PREFIX/lib/php]
--with-zend-vm=TYPE     Set virtual machine dispatch method. Type is
--with-tsrm-pth=pth-config
--with-tsrm-st          Use SGI's State Threads
--with-tsrm-pthreads    Use POSIX threads (default)
--with-gnu-ld           assume the C compiler uses GNU ld default=no
--with-pic              try to use only PIC/non-PIC objects default=use both
--with-tags=TAGS      include additional configurations automatic
--with-curlwrappers     EXPERIMENTAL: Use cURL for url streams