![PHP模塊一覽及簡要說明](http://p2.ttnews.xyz/loading.gif)
PHP 編譯完成後,可以通過一個簡單的函數 phpinfo() 查看關於 PHP 的所有信息。以下介紹的模塊一覽,皆全部來自於函數 phpinfo() 的輸出信息。
SAPI Modules
什麼是 SAPI?
SAPI 即 Server API, Server Application Programming Interface。
1、Apache 2.0 Handler(apache2handler)
用於 Apache 2 的模塊,當安裝的是 PHP 5 的時候,編譯出來的文件名是 libphp5.so;當安裝的是 PHP 7 的時候,編譯出來的文件名是 libphp7.so。
libphp5.so 或 libphp7.so 通常被安裝在 Apache 的安裝目錄下的 modules 目錄。
編譯的時候需指定參數 −−with-apxs2=FILE,比如 −−with-apxs2=/usr/local/apache/bin/apxs
2、CGI / FastCGI
CGI,意為 Common Gateway Interface。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個可執行文件名是 php-cgi。
3、CLI
CLI,意為 Command Line。命令行模式。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個可執行文件名是 php。
輸入 php -h 顯示其用法。
4、Embed
默認不編譯安裝,除非指定編譯參數 −−enable-embed
該模塊允許在 C/C++ 語言中調用 PHP 提供的函數。
5、FastCGI Process Manager
FastCGI Process Manager,也就是 FPM,PHP FastCGI 進程的管理器。
6、litespeed
用於 LiteSpeed 的模塊,默認不編譯。
通過指定編譯參數 −−with-litespeed 安裝。 Build PHP as litespeed module
7、phpdbg
從 PHP 5.6 開始,引入了 phpdbg,交互式調試器,用於 Debug PHP 程序,可以在不用修改代碼,不影響性能的情況下控制 PHP 的運行環境。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個可執行文件名是 phpdbg。
PHP 5.4 和 5.5 也可以單獨安裝該模塊。
PHP Modules
PHP 源碼自帶的擴展模塊,根據 PHP 版本的不同略有差別,大致為以下這麼 71 個模塊。
1、BC Math
通過指定編譯參數 −−enable-bcmath 安裝。 Enable bc style precision math functions
2、Bzip2
通過指定編譯參數 −−with-bz2=DIR 安裝。 Include BZip2 support
Debian/Ubuntu 需安裝 libbz2-dev 依賴包。
Redhat/CentOS 需安裝 bzip2-devel 依賴包。
3、Calendar
通過指定編譯參數 −−enable-calendar 安裝。 Enable support for calendar conversion
4、COM and .Net
Windows 專用擴展。COM 是指 Component Object Model,組件對象模型,是多項微軟技術與框架的基礎,包括OLE、OLE自動化、ActiveX、COM+、DCOM、Windows shell、DirectX、Windows Runtime。
5、ctype
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-ctype
6、cURL
通過指定編譯參數 −−with-curl=DIR 安裝。 Include cURL support
Debian/Ubuntu 需安裝 libcurl4-gnutls-dev 依賴包。
Redhat/CentOS 需安裝 curl-devel 依賴包。
7、Date/Time Support(date)
日期和時間函數,默認編譯安裝,不可禁止。
8、DBA
通過指定編譯參數 −−enable-dba 安裝。 Build DBA with bundled modules
該參數會默認自帶 3 個參數,−−with-cdb,−−enable-inifile,inifile-flatfile,若要禁止,則需通過參數−−without-cdb=DIR,−−disable-inifile,−−disable-flatfile 實現。
9、DB-LIB (MS SQL, Sybase)(pdo_dblib)
Windows 專用擴展。用於連接 SQL Server 和 Sybase 數據庫的 PDO 驅動擴展。
10、DOM
此擴展默認為啟用,Document Object Model。編譯時可通過下列選項禁用:−−disable-dom
11、enchant
通過指定編譯參數 −−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
通過指定編譯參數 −−enable-exif 安裝。 Enable EXIF (metadata from images) support
13、fileinfo
此擴展默認為啟用,fileinfo support。編譯時可通過下列選項禁用:−−disable-fileinfo
注意:在內存比較小的機器上編譯此擴展時可能會失敗,因此內存加 SWAP 的容量小於 480MB 時就不要安裝了。
14、Filter
此擴展默認為啟用,input filter support。編譯時可通過下列選項禁用:−−disable-filter
另如果要給此擴展指定 PCRE 安裝目錄的話,則還有以下的編譯參數。
−−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
通過指定編譯參數 −−enable-ftp 安裝。Enable FTP support
安裝該擴展還有個參數 −−with-openssl-dir=DIR FTP: openssl install prefix,可不指定,則使用系統自帶 openssl 庫。
17、GD imaging(gd)
通過指定編譯參數 −−with-gd=DIR 安裝。Include GD support. DIR is the GD library base install directory BUNDLED
這是一個打包式的依賴,需要依賴如下安裝包。
−−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
PHP5.4、PHP5.5、PHP5.6 則還有個
−−with-vpx-dir=DIR
Debian/Ubuntu 需安裝 libwebp-dev, libjpeg-dev, libpng-dev, libxpm-dev, libfreetype6-dev, libvpx-dev 依賴包。
Redhat/CentOS 需安裝 libwebp-devel, libjpeg-devel, libpng-devel, libXpm-devel, freetype-devel, libvpx-devel 依賴包。
18、GetText
通過指定編譯參數 −−with-gettext=DIR 安裝。Include GNU gettext support
Debian/Ubuntu 需安裝 gettext 依賴包。
Redhat/CentOS 需安裝 gettext, gettext-devel 依賴包。
19、GMP
通過指定編譯參數 −−with-gmp=DIR 安裝。Include GNU MP support
Debian/Ubuntu 需安裝 libgmp-dev 依賴包。
Redhat/CentOS 需安裝 gmp-devel 依賴包。
20、Hash
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-hash Disable hash support
21、iconv
此擴展默認為啟用,編譯時可通過下列選項禁用:−−without-iconv=DIR Exclude iconv support
22、IMAP
通過指定以下編譯參數。
−−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
編譯此選項時,PHP 需指定 libc-client.a 所在目錄。
23、InterBase
−−with-interbase=DIR Include Firebird support. DIR is the Firebird base install directory
24、Internationalization(intl)
通過指定編譯參數 −−enable-intl 安裝。 Enable internationalization support
25、json
此擴展默認為啟用,編譯時可通過下列選項禁用:−−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
此擴展默認為啟用,編譯時可通過下列選項禁用:−−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)
通過指定編譯參數 −−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 對 mbstring 是必要的。libmbfl 被捆綁到了 mbstring。
Debian/Ubuntu 需安裝 libonig2, libonig-dev 依賴包。
Redhat/CentOS 需安裝 oniguruma, oniguruma-devel 依賴包。
29、mcrypt
通過指定編譯參數 −−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
指定系統裡安裝的 MYSQL 的 mysql.sock 路徑。
−−with-pdo-mysql=DIR PDO: MySQL support. DIR is the MySQL base directory
指定系統裡安裝的 MYSQL 的基本目錄。若未指定,則默認安裝 mysqlnd(MySQL native driver)
31、MySQLi
−−with-mysqli=FILE Include MySQLi support. FILE is the path to mysql_config
指定系統裡安裝的 MYSQL 的目錄下的 mysql_config 文件路徑。
32、MySQLnd
通過指定編譯參數 −−enable-mysqlnd 安裝。 Enable mysqlnd explicitly, will be done implicitly when required by other extensions
另如果要給此擴展指定 libz 目錄的話,則還有以下的編譯參數。
−−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
系統裡安裝了 Oracle 數據庫的話,則指定為 $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 有很多種,一般使用如下編譯參數即可。
−−with-unixODBC=DIR Include unixODBC support /usr/local
Debian/Ubuntu 需安裝 unixodbc, unixodbc-dev 依賴包。
Redhat/CentOS 需安裝 unixODBC, unixODBC-devel 依賴包。
注意:PHP 默認會去 /usr/local/include 下去找頭文件 sqlext.h,所以還要做個軟鏈接。
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
通過指定編譯參數 −−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)
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-phar Disable phar support
41、PHP Data Objects(PDO)
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-pdo Disable PHP Data Objects support
42、Posix
此擴展默認為啟用,編譯時可通過下列選項禁用:−−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
此擴展默認為啟用。
49、Sessions
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-session Disable session support
另如果要給此擴展指定 mm 支持的話,則還有以下的編譯參數。
−−with-mm=DIR SESSION: Include mm support for session storage
50、Shared Memory Operations(shmop)
通過指定編譯參數 −−enable-shmop 安裝。 Enable shmop support
51、SimpleXML
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-simplexml Disable SimpleXML support
另如果要給此擴展指定 libxml2 目錄的話,則還有以下的編譯參數。
−−with-libxml-dir=DIR SimpleXML: libxml2 install prefix
52、SNMP
通過指定編譯參數 −−with-snmp=DIR 安裝。 Include SNMP support
另如果要給此擴展指定 openssl 目錄的話,則還有以下的編譯參數。
−−with-openssl-dir=DIR SNMP: openssl install prefix
Debian/Ubuntu 需安裝 libsnmp-dev 依賴包。
Redhat/CentOS 需安裝 net-snmp-devel 依賴包。
53、SOAP
通過指定編譯參數 −−enable-soap 安裝。 Enable SOAP support
另如果要給此擴展指定 libxml2 目錄的話,則還有以下的編譯參數。
−−with-libxml-dir=DIR SOAP: libxml2 install prefix
54、Sockets
通過指定編譯參數 −−enable-sockets 安裝。 Enable sockets support
55、SPL
此擴展默認為啟用。
56、SQLite3
此擴展默認為啟用,編譯時可通過下列選項禁用:−−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)
此擴展默認為啟用,編譯時可通過下列選項禁用:−−without-pdo-sqlite=DIR PDO: sqlite 3 support. DIR is the sqlite base install directory BUNDLED
58、System V Message based IPC
通過指定編譯參數 −−enable-sysvmsg 安裝。 Enable sysvmsg support
59、System V Semaphores
通過指定編譯參數 −−enable-sysvsem 安裝。 Enable System V semaphore support
60、System V Shared Memory
通過指定編譯參數 −−enable-sysvshm 安裝。 Enable the System V shared memory support
61、tidy
通過指定編譯參數 −−with-tidy=DIR 安裝。 Include TIDY support
一般需指定其目錄,−−with-tidy=/usr
Debian/Ubuntu 需安裝 libtidy-dev 依賴包。
Redhat/CentOS 需安裝 libtidy-devel 依賴包。
62、tokenizer
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-tokenizer Disable tokenizer support
63、WDDX
通過指定編譯參數 −−enable-wddx 安裝。 Enable WDDX support
另如果要給此擴展指定 libxml2 目錄的話,則還有以下的編譯參數。
−−with-libxml-dir=DIR WDDX: libxml2 install prefix
64、XMLReader
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-xmlreader Disable XMLReader support
另如果要給此擴展指定 libxml2 目錄的話,則還有以下的編譯參數。
−−with-libxml-dir=DIR XMLReader: libxml2 install prefix
65、xmlrpc
通過指定編譯參數 −−with-xmlrpc=DIR 安裝。 Include XMLRPC-EPI support
另如果要給此擴展指定 libxml2 和 iconv 目錄的話,則還有以下的編譯參數。
−−with-libxml-dir=DIR XMLRPC-EPI: libxml2 install prefix
−−with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI
66、XML
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-xml Disable XML support
67、XMLWriter
此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-xmlwriter Disable XMLWriter support
68、XSL
通過指定編譯參數 −−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
通過指定編譯參數 −−enable-zip 安裝。 Include Zip read/write support
另如果要給此擴展指定 libz, PCRE 和 libzip 目錄的話,則還有以下的編譯參數。
−−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
通過指定編譯參數 −−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 之後的版本,此擴展默認為啟用,編譯時可通過下列選項禁用:−−disable-opcache Disable Zend OPcache support
注意:默認編譯安裝不代表默認啟用,還需配置到 ini 文件裡才行。
另外,PHP 還有諸多的第三方擴展,框架,CMS,包管理工具等。舉幾個例子。
擴展: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
閱讀更多 小跑司令爺 的文章