linux PHP 編譯參數詳解

Fast-CGI:
./configure --prefix=/usr/local/php --enable-fastcgi --enable-force-cgi-redirect --with-config-file-path=/etc --with-zlib --with-mysql --with-xml --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-mbstring

PHP4-Server:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-config-file-path=/etc --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --enable-mbstring

PHP4-Max:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --mandir=/usr/share/man --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc --with-openssl=/usr/local/openssl-0.9.7e --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-bz2 --with-inifile --with-hyperwave --enable-xml --enable-track-vars --enable-dba --enable-dbase --enable-filepro --enable-ftp --enable-versioning --enable-memory-limit --enable-calendar --enable-session --enable-sockets --enable-sysmsg --enable-sysvsem --enable-sysvshm --enable-tokenizer --enable-overload --enable-ctype --enable-sigchild --enable-magic-quotes --enable-roxen-zts --enable-fastcgi --enable-dbx --enable-dio --enable-shmop --enable-mbstring

PHP5-Server:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir --with-bz2 --with-tiff-dir --with-libxml-dir --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/usr/lib/mysql --with-config-file-path=/etc --disable-ipv6 --enable-gd-native-ttf

PHP5-Standard:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --mandir=/usr/share/man --with-openssl=/usr/local/openssl-0.9.7e --with-zlib --with-bz2 --with-tiff-dir --with-libxml-dir --enable-dio --enable-ftp --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-bz2-dir --with-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc --disable-ipv6 --enable-gd-native-ttf

PHP5-Max:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --mandir=/usr/share/man --with-openssl=/usr/local/openssl-0.9.7e --with-zlib --with-bz2 --with-tiff-dir --with-libxml-dir --enable-dio --enable-ftp --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-bz2-dir --with-ttf --with-inifile --enable-dba --enable-dbase --enable-filepro --enable-versioning --enable-memory-limit --enable-calendar --enable-sockets --enable-sysvsem --enable-sigchild --enable-magic-quotes --enable-roxen-zts --enable-fastcgi --enable-dbx --enable-shmop --enable-mbstring --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc --disable-ipv6 --enable-gd-native-ttf

1. 配置參數:

./configure \
--prefix=/usr/local/php5 \

  php


--with-apxs2=/usr/local/httpd2/bin/apxs \
--with-bz2 \
--enable-zip \
--enable-calendar \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--enable-sqlite-utf8 \
--with-iconv=/usr/local/iconv \
--enable-mbstring \
--with-curl \
--with-snmp \
--with-tidy \
--enable-exif \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-ttf=/usr \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--with-ming=/usr/local \
--with-xmlrpc \
--enable-soap \
--enable-sockets \
--with-mcrypt \
--with-mhash \
--enable-shmop \
-enable-dba \
--with-gdbm \
--with-db4 \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-mcrypt=/usr/local \
--with-mhash=/usr/local \
--enable-pcntl \
說明: html

 

--prefix=/usr/local/php //指定 php 安裝目錄 
--with-apxs2=/usr/local/apache/bin/apxs //整合apache,apxs功能是使用mod_so中的LoadModule指令,加載指定模塊到 apache,要求 apache 要打開SO模塊
--with-config-file-path=/usr/local/php/etc //指定php.ini位置
--with-MySQL=/usr/local/mysql //mysql安裝目錄,對mysql的支持
--with-mysqli=/usr/local/mysql/bin/mysql_config //mysqli擴展技術不只能夠調用MySQL的存儲過程、處理MySQL事務,並且還可使訪問數據庫工做變得更加穩定。 
--enable-safe-mode 打開安全模式 
--enable-ftp 打開ftp的支持 
--enable-zip 打開對zip的支持 
--with-bz2 打開對bz2文件的支持 
--with-jpeg-dir 打開對jpeg圖片的支持 
--with-png-dir 打開對png圖片的支持 
--with-freetype-dir 打開對freetype字體庫的支持 
--without-iconv 關閉iconv函數,各類字符集間的轉換 
--with-libXML-dir 打開libxml2庫的支持 
--with-XMLrpc 打開xml-rpc的c語言 
--with-zlib-dir 打開zlib庫的支持 
--with-gd 打開gd庫的支持 
--enable-gd-native-ttf 支持TrueType字符串函數庫 
--with-curl 打開curl瀏覽工具的支持 
--with-curlwrappers 運用curl工具打開url流 
--with-ttf 打開freetype1.*的支持,能夠不加了 
--with-xsl 打開XSLT 文件支持,擴展了libXML2庫 ,須要libxslt軟件 
--with-gettext 打開gnu 的gettext 支持,編碼庫用到 
--with-pear 打開pear命令的支持,PHP擴展用的 
--enable-calendar 打開日曆擴展功能 
--enable-mbstring 多字節,字符串的支持 
--enable-bcmath 打開圖片大小調整,用到zabbix監控的時候用到了這個模塊
--enable-sockets 打開 sockets 支持
--enable-exif 圖片的元數據支持 
--enable-magic-quotes 魔術引用的支持 
--disable-rpath 關閉額外的運行庫文件 
--disable-debug 關閉調試模式 
--with-mime-magic=/usr/share/file/magic.mime 魔術頭文件位置

 

CGI方式安裝才用的參數:
mysql

 

--enable-fpm //打上PHP-fpm 補丁後纔有這個參數,CGI方式安裝的啓動程序
--enable-fastCGI //支持fastcgi方式啓動PHP
--enable-force-CGI-redirect //重定向方式啓動PHP
--with-ncurses //支持ncurses 屏幕繪製以及基於文本終端的圖形互動功能的動態庫
--enable-pcntl //freeTDS須要用到的,多是連接mssql 纔用到
--with-mcrypt //mcrypt算法的擴展
--with-mhash //mhash算法的擴展
以上函數庫須要安裝
--with-gmp 應該是支持一種規範
--enable-inline-optimization 優化線程
--with-openssl //openssl的支持,加密傳輸時用到的
--enable-dbase //創建DBA 做爲共享模塊
--with-pcre-dir=/usr/local/bin/pcre-config //perl的正則庫案安裝位置
--disable-dmalloc
--with-gdbm //dba的gdbm支持
--enable-sigchild
--enable-sysvsem
--enable-sysvshm
--enable-zend-multibyte //支持zend的多字節
--enable-mbregex
--enable-wddx
--enable-shmop
--enable-soap

 

1>指定了--with-apxs2=/usr/local/apache/bin/apxs之後,就不要再激活--enable-fpm和--enable-fastCGI,apxs是以php module的模式加載PHP的。
2>Mysql在編譯了Mysql開發library之後,能夠不用指定mysql的路徑。
3>PHP編譯存在基礎的依賴的關係,編譯PHP首先須要安裝XML擴展,由於php5核心默認打開了XML的支持,其餘的基礎庫,相應須要:
4>GD -> zlib, Png, Jpg, 若是須要支持其餘,仍須要根據實際狀況編譯擴展庫,ttf庫須要freetype庫的支持。
5>--enable-magic-quotes,是一個極其不推薦的參數,固然,若是你須要PHP爲你作這些底下的工做,實際上他也沒有很完全的解決問題。
6>-with-openssl,須要openssl庫。 linux

mysqli是MySQL團隊提供的MySQL驅動,具備不少實用的功能和典型特徵。不過他不是MySQL於PHP平臺最好的選擇,PDO被證明,是一個簡易、高併發性,並且易於建立和回收的標準接口。不過PDO也經歷了5.3之前的內存溢出的問題,在5.3之後,在讀取Oracle的LOB資源時,若不對內存進行限制,仍會內存溢出。 正則表達式

若是是產品模式,好像pear、shmop、ftp等,都不推薦使用,他們要作的事情,用C/C++,用Java,甚至其餘腳本語言,都有很好很快速的選擇,無需侷限於使用PHP去實現。不熟悉的類庫和不經常使用的庫,也不推薦使用。magic-quote、session.auto_start、PHP服務器信息、PHP報錯信息等在編譯完成後,應該第一時間關閉,避免暴露服務器信息。 算法

PHP對應的Web Server模式,Module、fastcgi、fpm只須要一種便可,服務器不是你的試驗田。fastcgi能夠選擇Nginx和lighttpd,其實Nginx也是使用lighttpd的spwan-fcgi進行fcgi進程管理的。fpm是使用PHP自身去管理多進程,有點相似一個後端代理。不管什麼模式,在發佈產品服務器,都應該作進程和線程調優,作足夠多的壓力測試,找出最好的進程數組合。 sql

選好一種PHP OPCode cache的擴展,這個也是很重要的,linux 2.6核心下,fcgi下,xcache有較好的實踐經驗,其餘的在併發數增長之後,性能衰減嚴重。 數據庫

若是真的想體驗,寧肯編譯多幾個PHP版本,也不要針對一個版本的PHP集合各類擴展,適應各類環境,這會讓把你本身逼進窘境的。 apache

 

 

 

-with-bz2 \ 打開對bz2文件的支持。
--enable-zip \ 打開對zip的支持。
--enable-calendar \ 打開日曆擴展。
--with-mysql=/usr/local/mysql \ mysql的支持
--with-pdo-mysql=/usr/local/mysql \ pdo的mysql支持。
--enable-sqlite-utf8 \ 使sqllite支持utf-8
--with-iconv=/usr/local/iconv \ 支持iconv
--enable-mbstring \ 支持mbstring
--with-curl \
--with-snmp \
--with-tidy \
--enable-exif \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-ttf=/usr \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--with-ming=/usr/local \
--with-xmlrpc \
--enable-soap \
--enable-sockets \
--with-mcrypt \
--with-mhash \
--enable-shmop \
-enable-dba \
--with-gdbm \
--with-db4 \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-mcrypt=/usr/local \
--with-mhash=/usr/local \
--enable-pcntl \ 後端

須要單獨安裝的擴展:

1. gd庫。
2. ming的擴展。
3. mhash和mcrypt的擴展。







詳細選項上,除了上述的安裝簡介外,也能夠在編譯時加入其它的選項。

apache模塊

語法: --with-apache=DIR

說明: 用本選項可讓 PHP 以apache的模塊方式使用,DIR 的字符串能夠是 /usr/local/apache 或其它安裝apache的目錄

範例: --with-apache=/var/lib/apache

fhttpd 服務器模塊

語法: --with-fhttpd=DIR

說明: 若使用 fttpd 服務器,可使用本指令編譯 PHP。用模塊的方式配合 fttpd 服務器,能夠有較好的效率。

Adabas D 數據

語法: --with-adabas=DIR

說明: 數據庫系統爲 Adabas D 數據庫時須要加本選項。關於 Adabas D 數據庫的細節,能夠參考 http://www.adabas.com。

範例: --with-adabas=/usr/local/adabasd

dBase 資料表

語法: --with-dbase

說明: 只要加本選項,不用其它的參數或函數庫,PHP 就會讓系統有存取 dBase 資料表的功能。

filePro 數據庫

語法: --with-filepro

說明: 不用指定數據庫路徑及其它函數庫等,能夠讀取 filePro 數據庫 (惟讀)。

mSQL 數據庫

語法: --with-msql=DIR

說明: 提供存取 mSQL 數據庫。更多的細節請參考 mSQL 的網站 http://www.hughes.com.au。

範例: --with-msql=/usr/local/Hughes

MySQL 數據庫

語法: --with-mysql=DIR

說明: 提供存取 MySQL 數據庫。更多的細節請參考 MySQL 的網站 http://www.tcx.se。

範例: --with-mysql=/usr/local/mysql

iODBC 數據庫裝置

語法: --with-iodbc=DIR

說明: 提供 ODBC 數據庫裝置,用來存取後端數據庫。更多的細節請參考 iODBC 的網站 http://www.iodbc.org。

範例: --with-iodbc=/usr/local/iodbc

OpenLink ODBC 數據庫裝置

語法: --with-openlink=DIR

說明: 使用 OpenLink ODBC 數據庫裝置,用來存取後端數據庫。更多的細節請參考 OpenLink ODBC 的網站 http://www.openlinksw.com。

範例: --with-openlink=/usr/local/openlink

Oracle 數據庫

語法: --with-oracle=DIR

說 明: 使用 Oracle 數據庫。Oracle 的版本要在 7.3 版以上。您也能夠在 PHP 程序中使用環境變量 ORACLE_HOME 來指定 Oracle 的路徑。更多有關 Oracle 的信息請參考 Oracle 的網站 http://www.oracle.com。

範例: --with-oracle=/export/app/oracle/product/7.3.2

PostgreSQL 數據庫

語法: --with-pgsql=DIR

說 明: 使用 PostgreSQL 數據庫。更多有關 PostgreSQL 的信息請參考 PostgreSQL 的網站 http://www.postgreSQL.org 或臺灣的 Mirror 站 http://postgresql.ccit.edu.tw。

範例: --with-pgsql=/usr/local/pgsql

Solid 數據庫

語法: --with-solid=DIR

說明: 使用 Solid 數據庫。更多有關 Solid 的信息請參考 Solid 的網站 http://www.solidtech.com。

範例: --with-solid=/usr/local/solid

Sybase 數據庫

語法: --with-sybase=DIR

說明: 使用 Sybase 數據庫。更多有關 Sybase 的信息請參考 Sybase 的網站 http://www.sybase.com。

範例: --with-sybase=/home/sybase

Sybase-CT 數據庫

語法: --with-sybase-ct=DIR

說明: 使用 Sybase-CT 數據庫。

範例: --with-sybase-ct=/home/sybase

Velocis 數據庫

語法: --with-velocis=DIR

說明: 使用 Velocis 數據庫。有關 Velocis 數據庫的進一步資料請參考 Raima 公司的網站 http://www.raima.com。

範例: --with-velocis=/usr/local/velocis

自訂 ODBC 數據庫驅動程序

語法: --with-custom-odbc=DIR

說明: 使用自訂的 ODBC 函數庫。固然,在使用本方式時要指定 CUSTOM_ODBC_LIBS 及 CFLAGS 變量。例如在 QNX 機器上使用 Sybase SQL Anywhere 時可能要配置系統環境變量 CFLAGS=-DODBC_QNX、LDFLAGS=-lunix 及 CUSTOM_ODBC_LIBS="-ldblib -lodbc",並要在 PHP 配置加入 --with-custom-odbc=/usr/lib/sqlany50

範例: --with-custom-odbc=/usr/local/odbc

不使用 ODBC 數據庫驅動程序

語法: --disable-unified-odbc

說 明: 使用本選項將使全部的 ODBC 數據庫驅動程序不做用。本選項不用指定路徑,而受本選項影響的選項有 --with-iodbc、--with-solid、--with-adabas、--with-velocis 及 --with-custom-odbc。

LDAP 目錄協議

語法: --with-ldap=DIR

說明: 若要使用目錄協議 (Lightweight Directory Access Protocol, LDAP) 則必需要打開本選項。有關 LDAP 的細節,能夠參考 RFC 文件的 RFC1777 及 RFC1778。

範例: --with-ldap=/usr/local/ldap.

mcrypt 編碼函數庫

語法: --with-mcrypt=DIR

說明: 當安裝了 mcrypt 函數庫後,可在編譯 PHP 時加入本選項,讓程序可使用編解碼功能。

範例: --with-mcrypt=/usr/local/include

Sys V 信號

語法: --enable-sysvsem

說明: 要使用 SysV 的信號 (semaphores) 機制,則要打開本選項。

XML 支持

語法: --with-xml

說明: 打開本選項能夠支持 James Clark's 寫的 XML 解析程序庫。

維護模式

語法: --enable-maintainer-mode

說明: 本選項通常不會打開,除非是 PHP 開發人員比較有用。

正則表達式程序庫

語法: --with-system-regex

說明: 若您須要額外的正則表達式功能,能夠加入本選項。

PHP 配置文件

語法: --with-config-file-path=DIR

說明: 用來指定 php3.ini 或 php4.ini 的路徑,供 PHP 初始化時使用。

範例: --with-config-file-path=/usr/local/lib

PHP 執行路徑

語法: --with-exec-dir=DIR

說明: 有時爲了系統的安全性考慮,會指定 PHP 程序必定要在哪一個目錄執行。

範例: --with-exec-dir=/usr/local/bin

調試模式

語法: --enable-debug

說明: 本選項通常不會使用,除非在開發 PHP 程序時比較有用。它能夠顯示額外的錯誤信息。

安全模式

語法: --enable-safe-mode

說明: 默認值是打開的,能夠對系統安全提供比較多的保護。

變量追蹤

語法: --enable-track-vars

說明: 讓 PHP 能 追蹤 HTTP_GET_VARS、HTTP_POST_VARS 及 HTTP_COOKIE_VARS 三個變量,通常是打開的。

自動加引入字符

語法: --enable-magic-quotes

說明: 可以讓程序在執行時自動加入反斜線的引入字符。

打開調試器

語法: --enable-debugger

說明: 打開內建的 PHP 調試器。目前本功能還在實驗階段,還沒有成熟。

取消路徑 (discard path)

語法: --enable-discard-path

說明: 打開這個選項,用戶就不能透過瀏覽器讀取 .htaccess 等和系統安全相關的文件。

高精確度數學函數

語法: --enable-bcmath

說明: 打開高精確度函數。必需要先安裝本函數庫,本選項方有效。

強制 CGI 重定向

語法: --enable-force-cgi-redirect

範 例: 若使用 CGI VERSION 模式來執行 PHP 的設,打開本選項會增長安全性。例如用戶讀 http://my.host/cgi-bin/php/secret/doc.html 遇到比較瞭解 PHP 系統的黑客級用戶可能會自已輸入如下網址 http://my.host/secret/doc.html 來讀取相關信息。若 PHP 和 Apache 編譯在一塊兒,讓 PHP 變成 Apache 的一部份,則不須要加入本選項。

不使用短的標記

語法: --disable-short-tags

說明: 配置本選項後,PHP 的程序就不能使用短的標記,必定要用的長標記。

引入遠端檔寧

語法: --enable-url-includes

說明: 配置本選項可以讓 PHP 程序能夠引入 (include) 遠端的 HTTP 或 FTP 服務器中的文件。

關閉語法效果

語法: --disable-syntax-hl

說明: 使用本選項會關閉 PHP 語法的彩色效果。

函數庫路徑

語法: CPPFLAGS=-IDIR 及 LDFLAGS=-LDIR

說明: 若 PHP 在安全或編譯所需的函數庫在值得的路徑,須要加入本選項,LDFLAGS 表示函數庫的路徑,CPPFLAGS 表示標頭文件的路徑。

範例: LDFLAGS=-L/my/lib/dir CPPFLAGS=-I/my/include/dir ./configure

相關文章
相關標籤/搜索