PHP 編譯完成後,能夠經過一個簡單的函數 phpinfo() 查看關於 PHP 的全部信息。如下介紹的模塊一覽,皆所有來自於函數 phpinfo() 的輸出信息。 php
什麼是 SAPI?
SAPI 即 Server API, Server Application Programming Interface。 html
用於 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 mysql
CGI,意爲 Common Gateway Interface。
一般編譯安裝在 PHP 安裝目錄 bin 下,這個可執行文件名是 php-cgi。 web
CLI,意爲 Command Line。命令行模式。
一般編譯安裝在 PHP 安裝目錄 bin 下,這個可執行文件名是 php。
輸入 php -h 顯示其用法。 sql
默認不編譯安裝,除非指定編譯參數 enable-embed
該模塊容許在 C/C++ 語言中調用 PHP 提供的函數。 shell
FastCGI Process Manager,也就是 FPM,PHP FastCGI 進程的管理器。 數據庫
用於 LiteSpeed 的模塊,默認不編譯。
經過指定編譯參數 with-litespeed 安裝。 Build PHP as litespeed module apache
從 PHP 5.6 開始,引入了 phpdbg,交互式調試器,用於 Debug PHP 程序,能夠在不用修改代碼,不影響性能的狀況下控制 PHP 的運行環境。
一般編譯安裝在 PHP 安裝目錄 bin 下,這個可執行文件名是 phpdbg。
PHP 5.4 和 5.5 也能夠單獨安裝該模塊。 json
PHP 源碼自帶的擴展模塊,根據 PHP 版本的不一樣略有差異,大體爲如下這麼 71 個模塊。 session
經過指定編譯參數 enable-bcmath 安裝。 Enable bc style precision math functions
經過指定編譯參數 with-bz2=DIR 安裝。 Include BZip2 support
Debian/Ubuntu 需安裝 libbz2-dev 依賴包。
Redhat/CentOS 需安裝 bzip2-devel 依賴包。
經過指定編譯參數 enable-calendar 安裝。 Enable support for calendar conversion
Windows 專用擴展。COM 是指 Component Object Model,組件對象模型,是多項微軟技術與框架的基礎,包括OLE、OLE自動化、ActiveX、COM+、DCOM、Windows shell、DirectX、Windows Runtime。
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-ctype
經過指定編譯參數 with-curl=DIR 安裝。 Include cURL support
Debian/Ubuntu 需安裝 libcurl4-gnutls-dev 依賴包。
Redhat/CentOS 需安裝 curl-devel 依賴包。
日期和時間函數,默認編譯安裝,不可禁止。
經過指定編譯參數 enable-dba 安裝。 Build DBA with bundled modules
該參數會默認自帶 3 個參數,with-cdb,enable-inifile,inifile-flatfile,若要禁止,則需經過參數without-cdb=DIR,disable-inifile,disable-flatfile 實現。
Windows 專用擴展。用於鏈接 SQL Server 和 Sybase 數據庫的 PDO 驅動擴展。
此擴展默認爲啓用,Document Object Model。編譯時可經過下列選項禁用:disable-dom
經過指定編譯參數 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 依賴包。
經過指定編譯參數 enable-exif 安裝。 Enable EXIF (metadata from p_w_picpaths) support
此擴展默認爲啓用,fileinfo support。編譯時可經過下列選項禁用:disable-fileinfo
注意:在內存比較小的機器上編譯此擴展時可能會失敗,所以內存加 SWAP 的容量小於 480MB 時就不要安裝了。
此擴展默認爲啓用,input filter support。編譯時可經過下列選項禁用:disable-filter
另若是要給此擴展指定 PCRE 安裝目錄的話,則還有如下的編譯參數。
with-pcre-dir FILTER: pcre install prefix
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
經過指定編譯參數 enable-ftp 安裝。Enable FTP support
安裝該擴展還有個參數 with-openssl-dir=DIR FTP: openssl install prefix,可不指定,則使用系統自帶 openssl 庫。
經過指定編譯參數 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.四、PHP5.五、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 依賴包。
經過指定編譯參數 with-gettext=DIR 安裝。Include GNU gettext support
Debian/Ubuntu 需安裝 gettext 依賴包。
Redhat/CentOS 需安裝 gettext, gettext-devel 依賴包。
經過指定編譯參數 with-gmp=DIR 安裝。Include GNU MP support
Debian/Ubuntu 需安裝 libgmp-dev 依賴包。
Redhat/CentOS 需安裝 gmp-devel 依賴包。
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-hash Disable hash support
此擴展默認爲啓用,編譯時可經過下列選項禁用:without-iconv=DIR Exclude iconv support
經過指定如下編譯參數。
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 所在目錄。
with-interbase=DIR Include Firebird support. DIR is the Firebird base install directory
經過指定編譯參數 enable-intl 安裝。 Enable internationalization support
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-json Disable JavaScript Object Serialization support
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 依賴包。
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-libxml Disable LIBXML support
with-libxml-dir=DIR LIBXML: libxml2 install prefix
Debian/Ubuntu 需安裝 libxml2, libxml2-dev 依賴包。
Redhat/CentOS 需安裝 libxml2, libxml2-devel 依賴包。
經過指定編譯參數 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 依賴包。
經過指定編譯參數 with-mcrypt=DIR 安裝。 Include mcrypt support
Debian/Ubuntu 需安裝 libmcrypt-dev 依賴包。
Redhat/CentOS 需編譯安裝 libmcrypt 和 mcrypt 。若是安裝了 EPEL 的話,則需安裝 libmcrypt-devel 依賴包。
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)
with-mysqli=FILE Include MySQLi support. FILE is the path to mysql_config
指定系統裏安裝的 MYSQL 的目錄下的 mysql_config 文件路徑。
經過指定編譯參數 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
with-oci8=DIR Include Oracle Database OCI8 support. DIR defaults to $ORACLE_HOME
系統裏安裝了 Oracle 數據庫的話,則指定爲 $ORACLE_HOME;不然需安裝 Oracle Instant Client,指定爲 /path/to/instant/client/lib
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
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/
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
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
經過指定編譯參數 enable-pcntl 安裝。 Enable pcntl support (CLI/CGI only)
with-pcre-regex=DIR Include Perl Compatible Regular Expressions support. DIR is the PCRE install prefix BUNDLED
with-pcre-jit Enable PCRE JIT functionality
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-phar Disable phar support
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-pdo Disable PHP Data Objects support
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-posix Disable POSIX-like functions
with-pdo-pgsql=DIR PDO: PostgreSQL support. DIR is the PostgreSQL base install directory or the path to pg_config
with-pgsql=DIR Include PostgreSQL support. DIR is the PostgreSQL base install directory or the path to pg_config
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 依賴包。
with-readline=DIR Include readline support (CLI/CGI only)
Debian/Ubuntu 需安裝 libreadline-dev 依賴包。
Redhat/CentOS 需安裝 readline-devel 依賴包。
with-recode=DIR nclude recode support
Debian/Ubuntu 需安裝 librecode-dev 依賴包。
Redhat/CentOS 需安裝 recode-devel 依賴包。
此擴展默認爲啓用。
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-session Disable session support
另若是要給此擴展指定 mm 支持的話,則還有如下的編譯參數。
with-mm=DIR SESSION: Include mm support for session storage
經過指定編譯參數 enable-shmop 安裝。 Enable shmop support
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-simplexml Disable SimpleXML support
另若是要給此擴展指定 libxml2 目錄的話,則還有如下的編譯參數。
with-libxml-dir=DIR SimpleXML: libxml2 install prefix
經過指定編譯參數 with-snmp=DIR 安裝。 Include SNMP support
另若是要給此擴展指定 openssl 目錄的話,則還有如下的編譯參數。
with-openssl-dir=DIR SNMP: openssl install prefix
Debian/Ubuntu 需安裝 libsnmp-dev 依賴包。
Redhat/CentOS 需安裝 net-snmp-devel 依賴包。
經過指定編譯參數 enable-soap 安裝。 Enable SOAP support
另若是要給此擴展指定 libxml2 目錄的話,則還有如下的編譯參數。
with-libxml-dir=DIR SOAP: libxml2 install prefix
經過指定編譯參數 enable-sockets 安裝。 Enable sockets support
此擴展默認爲啓用。
此擴展默認爲啓用,編譯時可經過下列選項禁用:without-sqlite3=DIR Do not include SQLite3 support. DIR is the prefix to SQLite3 installation directory
此擴展默認爲啓用,編譯時可經過下列選項禁用:without-pdo-sqlite=DIR PDO: sqlite 3 support. DIR is the sqlite base install directory BUNDLED
經過指定編譯參數 enable-sysvmsg 安裝。 Enable sysvmsg support
經過指定編譯參數 enable-sysvsem 安裝。 Enable System V semaphore support
經過指定編譯參數 enable-sysvshm 安裝。 Enable the System V shared memory support
經過指定編譯參數 with-tidy=DIR 安裝。 Include TIDY support
通常需指定其目錄,with-tidy=/usr
Debian/Ubuntu 需安裝 libtidy-dev 依賴包。
Redhat/CentOS 需安裝 libtidy-devel 依賴包。
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-tokenizer Disable tokenizer support
經過指定編譯參數 enable-wddx 安裝。 Enable WDDX support
另若是要給此擴展指定 libxml2 目錄的話,則還有如下的編譯參數。
with-libxml-dir=DIR WDDX: libxml2 install prefix
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-xmlreader Disable XMLReader support
另若是要給此擴展指定 libxml2 目錄的話,則還有如下的編譯參數。
with-libxml-dir=DIR XMLReader: libxml2 install prefix
經過指定編譯參數 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
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-xml Disable XML support
此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-xmlwriter Disable XMLWriter support
經過指定編譯參數 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 依賴包。
經過指定編譯參數 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
經過指定編譯參數 with-zlib=DIR 安裝。 Include ZLIB support (requires zlib >= 1.0.9)
Debian/Ubuntu 需安裝 zlib1g-dev 依賴包。
Redhat/CentOS 需安裝 zlib-devel 依賴包。
PHP 5.5 以後的版本,此擴展默認爲啓用,編譯時可經過下列選項禁用:disable-opcache Disable Zend OPcache support
注意:默認編譯安裝不表明默認啓用,還需配置到 ini 文件裏才行。
擴展: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
原文出處:https://teddysun.com/504.html
原文做者:秋水逸冰
感謝原文做者的技術分享!