SAPI Modules
什么是 SAPI?
SAPI 即 Server API, Server Application Programming Interface。
1、Apache 2.0 Handler(apache2handler)
用于 Apache 2 的模塊,當(dāng)安裝的是 PHP 5 的時(shí)候,編譯出來(lái)的文件名是 libphp5.so;當(dāng)安裝的是 PHP 7 的時(shí)候,編譯出來(lái)的文件名是 libphp7.so。
libphp5.so 或 libphp7.so 通常被安裝在 Apache 的安裝目錄下的 modules 目錄。
編譯的時(shí)候需指定參數(shù) ??with-apxs2=FILE,比如 ??with-apxs2=/usr/local/apache/bin/apxs
2、CGI / FastCGI
CGI,意為 Common Gateway Interface。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個(gè)可執(zhí)行文件名是 php-cgi。
3、CLI
CLI,意為 Command Line。命令行模式。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個(gè)可執(zhí)行文件名是 php。
輸入 php -h 顯示其用法。
4、Embed
默認(rèn)不編譯安裝,除非指定編譯參數(shù) ??enable-embed
該模塊允許在 C/C++ 語(yǔ)言中調(diào)用 PHP 提供的函數(shù)。
5、FastCGI Process Manager
FastCGI Process Manager,也就是 FPM,PHP FastCGI 進(jìn)程的管理器。
6、litespeed
用于 LiteSpeed 的模塊,默認(rèn)不編譯。
通過(guò)指定編譯參數(shù) ??with-litespeed 安裝。 Build PHP as litespeed module
7、phpdbg
從 PHP 5.6 開(kāi)始,引入了 phpdbg,交互式調(diào)試器,用于 Debug PHP 程序,可以在不用修改代碼,不影響性能的情況下控制 PHP 的運(yùn)行環(huán)境。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個(gè)可執(zhí)行文件名是 phpdbg。
PHP 5.4 和 5.5 也可以單獨(dú)安裝該模塊。
PHP Modules
PHP 源碼自帶的擴(kuò)展模塊,根據(jù) PHP 版本的不同略有差別,大致為以下這么 71 個(gè)模塊。
1、BC Math
通過(guò)指定編譯參數(shù) ??enable-bcmath 安裝。 Enable bc style precision math functions
2、Bzip2
通過(guò)指定編譯參數(shù) ??with-bz2=DIR 安裝。 Include BZip2 support
Debian/Ubuntu 需安裝 libbz2-dev 依賴包。
Redhat/CentOS 需安裝 bzip2-devel 依賴包。
3、Calendar
通過(guò)指定編譯參數(shù) ??enable-calendar 安裝。 Enable support for calendar conversion
4、COM and .Net
Windows 專用擴(kuò)展。COM 是指 Component Object Model,組件對(duì)象模型,是多項(xiàng)微軟技術(shù)與框架的基礎(chǔ),包括OLE、OLE自動(dòng)化、ActiveX、COM+、DCOM、Windows shell、DirectX、Windows Runtime。
5、ctype
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-ctype
6、cURL
通過(guò)指定編譯參數(shù) ??with-curl=DIR 安裝。 Include cURL support
Debian/Ubuntu 需安裝 libcurl4-gnutls-dev 依賴包。
Redhat/CentOS 需安裝 curl-devel 依賴包。
7、Date/Time Support(date)
日期和時(shí)間函數(shù),默認(rèn)編譯安裝,不可禁止。
8、DBA
通過(guò)指定編譯參數(shù) ??enable-dba 安裝。 Build DBA with bundled modules
該參數(shù)會(huì)默認(rèn)自帶 3 個(gè)參數(shù),??with-cdb,??enable-inifile,inifile-flatfile,若要禁止,則需通過(guò)參數(shù)??without-cdb=DIR,??disable-inifile,??disable-flatfile 實(shí)現(xiàn)。
9、DB-LIB (MS SQL, Sybase)(pdo_dblib)
Windows 專用擴(kuò)展。用于連接? SQL Server 和 Sybase 數(shù)據(jù)庫(kù)的 PDO 驅(qū)動(dòng)擴(kuò)展。
10、DOM
此擴(kuò)展默認(rèn)為啟用,Document Object Model。編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-dom
11、enchant
通過(guò)指定編譯參數(shù) ??with-enchant=DIR 安裝。 Include enchant support. GNU Aspell version 1.1.3 or higher required.
一般需指定其目錄,??with-enchant=/usr
Debian/Ubuntu 需安裝 libenchant-dev, libpspell-dev 依賴包。
Redhat/CentOS 需安裝 enchant-devel, aspell-devel 依賴包。
12、EXIF
通過(guò)指定編譯參數(shù) ??enable-exif 安裝。 Enable EXIF (metadata from images) support
13、fileinfo
此擴(kuò)展默認(rèn)為啟用,fileinfo support。編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-fileinfo
注意:在內(nèi)存比較小的機(jī)器上編譯此擴(kuò)展時(shí)可能會(huì)失敗,因此內(nèi)存加 SWAP 的容量小于 480MB 時(shí)就不要安裝了。
14、Filter
此擴(kuò)展默認(rèn)為啟用,input filter support。編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-filter
另如果要給此擴(kuò)展指定 PCRE 安裝目錄的話,則還有以下的編譯參數(shù)。
??with-pcre-dir? FILTER: pcre install prefix
15、Firebird driver for PDO(pdo_firebird)
??with-interbase=DIR Include Firebird support.? DIR is the Firebird base install directory
??with-pdo-firebird=DIR PDO: Firebird support.? DIR is the Firebird base install directory
16、FTP
通過(guò)指定編譯參數(shù) ??enable-ftp 安裝。Enable FTP support
安裝該擴(kuò)展還有個(gè)參數(shù) ??with-openssl-dir=DIR? FTP: openssl install prefix,可不指定,則使用系統(tǒng)自帶 openssl 庫(kù)。
17、GD imaging(gd)
通過(guò)指定編譯參數(shù) ??with-gd=DIR 安裝。Include GD support.? DIR is the GD library base install directory BUNDLED
這是一個(gè)打包式的依賴,需要依賴如下安裝包。
??with-webp-dir=DIR(PHP 7.0, 7.1 only)
??with-jpeg-dir=DIR
??with-png-dir=DIR
??with-zlib-dir=DIR
??with-xpm-dir=DIR
??with-freetype-dir=DIR
??enable-gd-native-ttf
??enable-gd-jis-conv
??with-vpx-dir=DIR
Redhat/CentOS 需安裝 libwebp-devel, libjpeg-devel, libpng-devel, libXpm-devel, freetype-devel, libvpx-devel 依賴包。
18、GetText
通過(guò)指定編譯參數(shù) ??with-gettext=DIR 安裝。Include GNU gettext support
Debian/Ubuntu 需安裝 gettext 依賴包。
Redhat/CentOS 需安裝 gettext, gettext-devel 依賴包。
19、GMP
通過(guò)指定編譯參數(shù) ??with-gmp=DIR 安裝。Include GNU MP support
Debian/Ubuntu 需安裝 libgmp-dev 依賴包。
Redhat/CentOS 需安裝 gmp-devel 依賴包。
20、Hash
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-hash? Disable hash support
21、iconv
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??without-iconv=DIR? Exclude iconv support
22、IMAP
通過(guò)指定以下編譯參數(shù)。
??with-imap=DIR???????? Include IMAP support. DIR is the c-client install prefix
??with-kerberos=DIR???? IMAP: Include Kerberos support. DIR is the Kerberos install prefix
??with-imap-ssl=DIR???? IMAP: Include SSL support. DIR is the OpenSSL install prefix
編譯此選項(xiàng)時(shí),PHP 需指定 libc-client.a 所在目錄。
23、InterBase
??with-interbase=DIR Include Firebird support.? DIR is the Firebird base install directory
24、Internationalization(intl)
通過(guò)指定編譯參數(shù) ??enable-intl 安裝。 Enable internationalization support
25、json
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-json? Disable JavaScript Object Serialization support
26、LDAP
??with-ldap=DIR???????? Include LDAP support
??with-ldap-sasl=DIR??? LDAP: Include Cyrus SASL support
Debian/Ubuntu 需安裝 libldap-2.4-2, libldap2-dev 依賴包。
Redhat/CentOS 需安裝 openldap, openldap-devel 依賴包。
27、libxml
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-libxml? Disable LIBXML support
??with-libxml-dir=DIR?? LIBXML: libxml2 install prefix
Debian/Ubuntu 需安裝 libxml2, libxml2-dev 依賴包。
Redhat/CentOS 需安裝 libxml2, libxml2-devel 依賴包。
28、Multibyte String Functions(mbstring)
通過(guò)指定編譯參數(shù) ??enable-mbstring 安裝。 Enable multibyte string support
??disable-mbregex? MBSTRING: Disable multibyte regex support
??disable-mbregex-backtrack? MBSTRING: Disable multibyte regex backtrack check
??with-libmbfl=DIR? MBSTRING: Use external libmbfl.? DIR is the libmbfl base install directory BUNDLED
??with-onig=DIR? MBSTRING: Use external oniguruma. DIR is the oniguruma install prefix. If DIR is not set, the bundled oniguruma will be used
libmbfl 對(duì) mbstring 是必要的。libmbfl 被捆綁到了 mbstring。
Debian/Ubuntu 需安裝 libonig2, libonig-dev 依賴包。
Redhat/CentOS 需安裝 oniguruma, oniguruma-devel 依賴包。
29、mcrypt
通過(guò)指定編譯參數(shù)? ??with-mcrypt=DIR 安裝。? Include mcrypt support
Debian/Ubuntu 需安裝 libmcrypt-dev 依賴包。
Redhat/CentOS 需編譯安裝 libmcrypt 和 mcrypt 。如果安裝了 EPEL 的話,則需安裝 libmcrypt-devel 依賴包。
30、MySQL driver for PDO(pdo_mysql)
??with-mysql-sock=SOCKPATH? MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer
指定系統(tǒng)里安裝的 MYSQL 的 mysql.sock 路徑。
??with-pdo-mysql=DIR? PDO: MySQL support. DIR is the MySQL base directory
指定系統(tǒng)里安裝的 MYSQL 的基本目錄。若未指定,則默認(rèn)安裝 mysqlnd(MySQL native driver)
31、MySQLi
??with-mysqli=FILE? Include MySQLi support. FILE is the path to mysql_config
指定系統(tǒng)里安裝的 MYSQL 的目錄下的 mysql_config 文件路徑。
32、MySQLnd
通過(guò)指定編譯參數(shù) ??enable-mysqlnd 安裝。 Enable mysqlnd explicitly, will be done implicitly when required by other extensions
另如果要給此擴(kuò)展指定 libz 目錄的話,則還有以下的編譯參數(shù)。
??with-zlib-dir=DIR? mysqlnd: Set the path to libz install prefix
33、OCI8
??with-oci8=DIR? Include Oracle Database OCI8 support. DIR defaults to $ORACLE_HOME
系統(tǒng)里安裝了 Oracle 數(shù)據(jù)庫(kù)的話,則指定為 $ORACLE_HOME;否則需安裝 Oracle Instant Client,指定為 /path/to/instant/client/lib
34、ODBC driver for PDO(pdo_odbc)
??with-pdo-odbc=flavour,dir
PDO: Support for ‘flavour’ ODBC driver.
include and lib dirs are looked for under ‘dir’.
‘flavour’ can be one of:? ibm-db2, iODBC, unixODBC, generic
If ‘,dir’ part is omitted, default for the flavour
you have selected will be used. e.g.:
??with-pdo-odbc=unixODBC
will check for unixODBC under /usr/local. You may attempt to use an otherwise unsupported driver using the “generic” flavour.
The syntax for generic ODBC support is:
??with-pdo-odbc=generic,dir,libname,ldflags,cflags
When built as ‘shared’ the extension filename is always pdo_odbc.so
35、ODBC
ODBC 有很多種,一般使用如下編譯參數(shù)即可。
??with-unixODBC=DIR? Include unixODBC support /usr/local
Debian/Ubuntu 需安裝 unixodbc, unixodbc-dev 依賴包。
Redhat/CentOS 需安裝 unixODBC, unixODBC-devel 依賴包。
注意:PHP 默認(rèn)會(huì)去 /usr/local/include 下去找頭文件 sqlext.h,所以還要做個(gè)軟鏈接。
ln -s /usr/include/sqlext.h /usr/local/include/
36、OpenSSL
??with-openssl=DIR????? Include OpenSSL support (requires OpenSSL >= 1.0.1)
??with-kerberos=DIR???? OPENSSL: Include Kerberos support
??with-system-ciphers?? OPENSSL: Use system default cipher list instead of hardcoded value
PHP 7.1 所需的 openssl 版本是 >= 1.0.1
PHP 7.0 所需的 openssl 版本是 >= 0.9.8
PHP 5.6 所需的 openssl 版本是 >= 0.9.6
PHP 5.5 所需的 openssl 版本是 >= 0.9.6
PHP 5.4 所需的 openssl 版本是 >= 0.9.6
PHP 5.3 所需的 openssl 版本是 >= 0.9.6
37、Oracle (OCI) driver for PDO(pdo_oci)
??with-pdo-oci=DIR? PDO: Oracle OCI support. DIR defaults to $ORACLE_HOME.
Use ??with-pdo-oci=instantclient,prefix,version for an Oracle Instant Client SDK.
For example on Linux with 11.2 RPMs use:
??with-pdo-oci=instantclient,/usr,11.2
38、pcntl
通過(guò)指定編譯參數(shù) ??enable-pcntl 安裝。 Enable pcntl support (CLI/CGI only)
39、Perl Compatible Regular Expressions(PCRE)
??with-pcre-regex=DIR?? Include Perl Compatible Regular Expressions support. DIR is the PCRE install prefix BUNDLED
??with-pcre-jit? Enable PCRE JIT functionality
40、PHP Archive(Phar)
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-phar? Disable phar support
41、PHP Data Objects(PDO)
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-pdo? Disable PHP Data Objects support
42、Posix
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-posix? Disable POSIX-like functions
43、PostgreSQL driver for PDO(pdo_pgsql)
??with-pdo-pgsql=DIR? PDO: PostgreSQL support.? DIR is the PostgreSQL base install directory or the path to pg_config
44、PostgreSQL
??with-pgsql=DIR? Include PostgreSQL support.? DIR is the PostgreSQL base install directory or the path to pg_config
45、Pspell
??with-pspell=DIR? Include PSPELL support. GNU Aspell version 0.50.0 or higher required
一般需指定其目錄,??with-pspell=/usr
Debian/Ubuntu 需安裝 libpspell-dev 依賴包。
Redhat/CentOS 需安裝 aspell-devel 依賴包。
46、Readline
??with-readline=DIR? Include readline support (CLI/CGI only)
Debian/Ubuntu 需安裝 libreadline-dev 依賴包。
Redhat/CentOS 需安裝 readline-devel 依賴包。
47、Recode
??with-recode=DIR? nclude recode support
Debian/Ubuntu 需安裝 librecode-dev 依賴包。
Redhat/CentOS 需安裝 recode-devel 依賴包。
48、Reflection
此擴(kuò)展默認(rèn)為啟用。
49、Sessions
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-session? Disable session support
另如果要給此擴(kuò)展指定 mm 支持的話,則還有以下的編譯參數(shù)。
??with-mm=DIR? SESSION: Include mm support for session storage
50、Shared Memory Operations(shmop)
通過(guò)指定編譯參數(shù) ??enable-shmop 安裝。 Enable shmop support
51、SimpleXML
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-simplexml? Disable SimpleXML support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
??with-libxml-dir=DIR? SimpleXML: libxml2 install prefix
52、SNMP
通過(guò)指定編譯參數(shù) ??with-snmp=DIR 安裝。 Include SNMP support
另如果要給此擴(kuò)展指定 openssl 目錄的話,則還有以下的編譯參數(shù)。
??with-openssl-dir=DIR? SNMP: openssl install prefix
Debian/Ubuntu 需安裝 libsnmp-dev 依賴包。
Redhat/CentOS 需安裝 net-snmp-devel 依賴包。
53、SOAP
通過(guò)指定編譯參數(shù) ??enable-soap 安裝。 Enable SOAP support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
??with-libxml-dir=DIR? SOAP: libxml2 install prefix
54、Sockets
通過(guò)指定編譯參數(shù) ??enable-sockets 安裝。 Enable sockets support
55、SPL
此擴(kuò)展默認(rèn)為啟用。
56、SQLite3
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??without-sqlite3=DIR? Do not include SQLite3 support. DIR is the prefix to SQLite3 installation directory
57、SQLite 3.x driver for PDO(pdo_sqlite)
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??without-pdo-sqlite=DIR? PDO: sqlite 3 support. DIR is the sqlite base install directory BUNDLED
58、System V Message based IPC
通過(guò)指定編譯參數(shù) ??enable-sysvmsg 安裝。 Enable sysvmsg support
59、System V Semaphores
通過(guò)指定編譯參數(shù) ??enable-sysvsem 安裝。 Enable System V semaphore support
60、System V Shared Memory
通過(guò)指定編譯參數(shù) ??enable-sysvshm 安裝。 Enable the System V shared memory support
61、tidy
通過(guò)指定編譯參數(shù) ??with-tidy=DIR 安裝。 Include TIDY support
一般需指定其目錄,??with-tidy=/usr
Debian/Ubuntu 需安裝 libtidy-dev 依賴包。
Redhat/CentOS 需安裝 libtidy-devel 依賴包。
62、tokenizer
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-tokenizer? Disable tokenizer support
63、WDDX
通過(guò)指定編譯參數(shù) ??enable-wddx 安裝。 Enable WDDX support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
??with-libxml-dir=DIR? WDDX: libxml2 install prefix
64、XMLReader
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-xmlreader? Disable XMLReader support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
??with-libxml-dir=DIR? XMLReader: libxml2 install prefix
65、xmlrpc
通過(guò)指定編譯參數(shù) ??with-xmlrpc=DIR 安裝。 Include XMLRPC-EPI support
另如果要給此擴(kuò)展指定 libxml2 和 iconv 目錄的話,則還有以下的編譯參數(shù)。
??with-libxml-dir=DIR? XMLRPC-EPI: libxml2 install prefix
??with-iconv-dir=DIR? XMLRPC-EPI: iconv dir for XMLRPC-EPI
66、XML
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-xml? Disable XML support
67、XMLWriter
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-xmlwriter? Disable XMLWriter support
68、XSL
通過(guò)指定編譯參數(shù) ??with-xsl=DIR 安裝。 Include XSL support.? DIR is the libxslt base install directory (libxslt >= 1.1.0 required)
Debian/Ubuntu 需安裝 libxslt1-dev 依賴包。
Redhat/CentOS 需安裝 libxslt-devel 依賴包。
69、Zip
通過(guò)指定編譯參數(shù) ??enable-zip 安裝。 Include Zip read/write support
另如果要給此擴(kuò)展指定 libz, PCRE 和 libzip 目錄的話,則還有以下的編譯參數(shù)。
??with-zlib-dir=DIR? ZIP: Set the path to libz install prefix
??with-pcre-dir=DIR? ZIP: pcre install prefix
??with-libzip=DIR? ZIP: use libzip
70、Zlib
通過(guò)指定編譯參數(shù) ??with-zlib=DIR 安裝。 Include ZLIB support (requires zlib >= 1.0.9)
Debian/Ubuntu 需安裝 zlib1g-dev 依賴包。
Redhat/CentOS 需安裝 zlib-devel 依賴包。
71、Zend OPcache
PHP 5.5 之后的版本,此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過(guò)下列選項(xiàng)禁用:??disable-opcache? Disable Zend OPcache support
注意:默認(rèn)編譯安裝不代表默認(rèn)啟用,還需配置到 ini 文件里才行。
另外,PHP 還有諸多的第三方擴(kuò)展,框架,CMS,包管理工具等。舉幾個(gè)例子。
擴(kuò)展:ZendGuardLoader, ionCube Loader, XCache, Imagemagick, GraphicsMagick, Memcached, Redis, Mongodb, Swoole
框架:Laravel, Symfony, Nette, Yii, Zend Framework, Silex, Slim, CakePHP, ThinkPHP
CMS:Wordpress, Drupal, Joomla, Typecho, Phpcms,
包管理工具:Composer






















