PHP 編譯完成后,可以通過一個(gè)簡(jiǎn)單的函數(shù) phpinfo() 查看關(guān)于 PHP 的所有信息。以下介紹的模塊一覽,皆全部來自于函數(shù) phpinfo()
什么是 SAPI?
SAPI 即 Server API, Server application Programming Inte***ce。
用于 Apache 2 的模塊,當(dāng)安裝的是 PHP 5 的時(shí)候,編譯出來的文件名是 libphp5.so;當(dāng)安裝的是 PHP 7 的時(shí)候,編譯出來的文件名是 libphp7.so。
libphp5.so 或 libphp7.so 通常被安裝在 Apache 的安裝目錄下的 modules 目錄。
編譯的時(shí)候需指定參數(shù) −−with-apxs2=FILE,比如 −−with-apxs2=/usr/local/apache/bin/apxs
CGI,意為 Common Gateway Inte***ce。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個(gè)可執(zhí)行文件名是 php-cgi。
CLI,意為 Command Line。命令行模式。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個(gè)可執(zhí)行文件名是 php。
輸入 php -h 顯示其用法。
默認(rèn)不編譯安裝,除非指定編譯參數(shù) −−enable-embed
該模塊允許在 C/C++ 語言中調(diào)用 PHP 提供的函數(shù)。
FastCGI Process Manager,也就是 FPM,PHP FastCGI 進(jìn)程的管理器。
用于 LiteSpeed 的模塊,默認(rèn)不編譯。
通過指定編譯參數(shù) −−with-litespeed 安裝。 Build PHP as litespeed module
從 PHP 5.6 開始,引入了 phpdbg,交互式調(diào)試器,用于 Debug PHP 程序,可以在不用修改代碼,不影響性能的情況下控制 PHP 的運(yùn)行環(huán)境。
通常編譯安裝在 PHP 安裝目錄 bin 下,這個(gè)可執(zhí)行文件名是 phpdbg。
PHP 5.4 和 5.5 也可以單獨(dú)安裝該模塊。
PHP 源碼自帶的擴(kuò)展模塊,根據(jù) PHP 版本的不同略有差別,大致為以下這么 71 個(gè)模塊。
通過指定編譯參數(shù) −−enable-bcmath 安裝。 Enable bc style precision math functions
通過指定編譯參數(shù) −−with-bz2=DIR 安裝。 Include BZip2 support
Debian/Ubuntu 需安裝 libbz2-dev 依賴包。
REDhat/CentOS 需安裝 bzip2-devel 依賴包。
通過指定編譯參數(shù) −−enable-calendar 安裝。 Enable support for calendar conversion
Windows 專用擴(kuò)展。COM 是指 Component Object Model,組件對(duì)象模型,是多項(xiàng)微軟技術(shù)與框架的基礎(chǔ),包括OLE、OLE自動(dòng)化、ActiveX、COM+、DCOM、Windows shell、DirectX、Windows Runtime。
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-ctype
通過指定編譯參數(shù) −−with-curl=DIR 安裝。 Include cURL support
Debian/Ubuntu 需安裝 libcurl4-gnutls-dev 依賴包。
Redhat/CentOS 需安裝 curl-devel 依賴包。
日期和時(shí)間函數(shù),默認(rèn)編譯安裝,不可禁止。
通過指定編譯參數(shù) −−enable-dba 安裝。 Build DBA with bundled modules
該參數(shù)會(huì)默認(rèn)自帶 3 個(gè)參數(shù),−−with-cdb,−−enable-inifile,inifile-flatfile,若要禁止,則需通過參數(shù)−−without-cdb=DIR,−−disable-inifile,−−disable-flatfile 實(shí)現(xiàn)。
Windows 專用擴(kuò)展。用于連接 SQL Server 和 Sybase 數(shù)據(jù)庫的 PDO 驅(qū)動(dòng)擴(kuò)展。
此擴(kuò)展默認(rèn)為啟用,document Object Model。編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-dom
通過指定編譯參數(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 依賴包。
通過指定編譯參數(shù) −−enable-exif 安裝。 Enable EXIF (metadata from images) support
此擴(kuò)展默認(rèn)為啟用,fileinfo support。編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-fileinfo
注意:在內(nèi)存比較小的機(jī)器上編譯此擴(kuò)展時(shí)可能會(huì)失敗,因此內(nèi)存加 SWAP 的容量小于 480MB 時(shí)就不要安裝了。
此擴(kuò)展默認(rèn)為啟用,input filter support。編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-filter
另如果要給此擴(kuò)展指定 PCRE 安裝目錄的話,則還有以下的編譯參數(shù)。
−−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
通過指定編譯參數(shù) −−enable-ftp 安裝。Enable FTP support
安裝該擴(kuò)展還有個(gè)參數(shù) −−with-openssl-dir=DIR FTP: openssl install prefix,可不指定,則使用系統(tǒng)自帶 openssl 庫。
通過指定編譯參數(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
通過指定編譯參數(shù) −−with-gettext=DIR 安裝。Include GNU gettext support
Debian/Ubuntu 需安裝 gettext 依賴包。
Redhat/CentOS 需安裝 gettext, gettext-devel 依賴包。
通過指定編譯參數(shù) −−with-gmp=DIR 安裝。Include GNU MP support
Debian/Ubuntu 需安裝 libgmp-dev 依賴包。
Redhat/CentOS 需安裝 gmp-devel 依賴包。
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-hash Disable hash support
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−without-iconv=DIR Exclude iconv support
通過指定以下編譯參數(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 所在目錄。
−−with-interbase=DIR Include Firebird support. DIR is the Firebird base install directory
通過指定編譯參數(shù) −−enable-intl 安裝。 Enable internationalization support
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−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 依賴包。
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(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 依賴包。
通過指定編譯參數(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 依賴包。
通過指定編譯參數(shù) −−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
指定系統(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)
−−with-mysqli=FILE Include MySQLi support. FILE is the path to mysql_config
指定系統(tǒng)里安裝的 MYSQL 的目錄下的 mysql_config 文件路徑。
通過指定編譯參數(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
−−with-oci8=DIR Include Oracle Database OCI8 support. DIR defaults to $ORACLE_HOME
系統(tǒng)里安裝了 Oracle 數(shù)據(jù)庫的話,則指定為 $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 有很多種,一般使用如下編譯參數(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/
−−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
通過指定編譯參數(shù) −−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
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-phar Disable phar support
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-pdo Disable PHP Data Objects support
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−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 依賴包。
此擴(kuò)展默認(rèn)為啟用。
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-session Disable session support
另如果要給此擴(kuò)展指定 mm 支持的話,則還有以下的編譯參數(shù)。
−−with-mm=DIR SESSION: Include mm support for session storage
通過指定編譯參數(shù) −−enable-shmop 安裝。 Enable shmop support
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-***xml Disable ***XML support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
−−with-libxml-dir=DIR ***XML: libxml2 install prefix
通過指定編譯參數(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 依賴包。
通過指定編譯參數(shù) −−enable-soap 安裝。 Enable SOAP support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
−−with-libxml-dir=DIR SOAP: libxml2 install prefix
通過指定編譯參數(shù) −−enable-sockets 安裝。 Enable sockets support
此擴(kuò)展默認(rèn)為啟用。
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−without-sqlite3=DIR Do not include SQLite3 support. DIR is the prefix to SQLite3 installation directory
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−without-pdo-sqlite=DIR PDO: sqlite 3 support. DIR is the sqlite base install directory BUNDLED
通過指定編譯參數(shù) −−enable-sysvmsg 安裝。 Enable sysvmsg support
通過指定編譯參數(shù) −−enable-sysvsem 安裝。 Enable System V semaphore support
通過指定編譯參數(shù) −−enable-sysvshm 安裝。 Enable the System V shared memory support
通過指定編譯參數(shù) −−with-tidy=DIR 安裝。 Include TIDY support
一般需指定其目錄,−−with-tidy=/usr
Debian/Ubuntu 需安裝 libtidy-dev 依賴包。
Redhat/CentOS 需安裝 libtidy-devel 依賴包。
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-tokenizer Disable tokenizer support
通過指定編譯參數(shù) −−enable-wddx 安裝。 Enable WDDX support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
−−with-libxml-dir=DIR WDDX: libxml2 install prefix
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-xmlreader Disable XMLReader support
另如果要給此擴(kuò)展指定 libxml2 目錄的話,則還有以下的編譯參數(shù)。
−−with-libxml-dir=DIR XMLReader: libxml2 install prefix
通過指定編譯參數(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
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-xml Disable XML support
此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-xmlwriter Disable XMLWriter support
通過指定編譯參數(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 依賴包。
通過指定編譯參數(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
通過指定編譯參數(shù) −−with-zlib=DIR 安裝。 Include ZLIB support (requires zlib >= 1.0.9)
Debian/Ubuntu 需安裝 zlib1g-dev 依賴包。
Redhat/CentOS 需安裝 zlib-devel 依賴包。
PHP 5.5 之后的版本,此擴(kuò)展默認(rèn)為啟用,編譯時(shí)可通過下列選項(xiàng)禁用:−−disable-opcache Disable Zend OPcache support
注意:默認(rèn)編譯安裝不代表默認(rèn)啟用,還需配置到 ini 文件里才行。
擴(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
微信掃碼關(guān)注 億華聯(lián)眾 公眾號(hào)