yum groupinstall "Development tools" yum -y install gcc gcc-c++ make cmake automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel openldap openldap-devellibxslt-devel
configure: error: xml2-config not found. Please check your libxml2 installation.php
yum install libxml2-devel
configure: error: Cannot find OpenSSL’shtml
yum install openssl-devel
configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/mysql
yum install curl-devel
configure: error: libjpeg.(a|so) not foundlinux
yum install libjpeg-devel
configure: error: libpng.(a|so) not found.c++
yum install libpng-devel
configure: error: libXpm.(a|so) not found.算法
yum install libXpm-devel
configure: error: freetype.h not found.sql
yum install freetype-devel
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.shell
yum install libc-client-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.數據庫
yum install libmcrypt-devel
configure: error: Please reinstall libmhash – I cannot find mhash.hapache
yum install mhash-devel
configure: error: Cannot find MySQL header files under /usr.Note that the MySQL client library is not bundled anymore!
yum install mysql-devel
configure: error: Please reinstall ming distribution. libming.(a|so) not found- temp remove the config for ‘–with-ming=/opt/ming/’configure: error: Cannot find pspell
yum install pspell-devel
configure: error: cannot find mm libraryDownload from http://www.ossp.org/pkg/lib/mm/
wget tar -zxvf mm-1.4.2.tar.gz ./configure make make install
configure: error: Cannot find libtidy
yum install libtidy-devel yum install libtidy
change path at configure: ‘–with-tidy=/usr’
configure: error: not found. Please reinstall the expat distribution.
yum install expat-devel
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum install libxslt-devel
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
cp -frp /usr/lib64/libldap* /usr/lib/
configure: error: Cannot find ldap.h
yum install openldap yum install openldap-devel
在PHP源碼目錄下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make便可。
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor': /home/king/php-5.2.13/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open' collect2: ld returned 1 exit status make: *** [sapi/cli/php] Error 1 [root@test php-5.2.13]# vi Makefile make ZEND_EXTRA_LIBS='-liconv' ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/
*Tips: To uninstall, just enter:yum remove {package-name}
apache是以apsx的模塊模式運行php,因此在--with-apxs2後就不要在--enable-fpm和--enable-fastCGI了
./configure \ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-apxs2=/usr/local/apache/bin/apxs \ --with-mysql=/usr/local/mysql \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-pdo-mysql=mysqlnd \ --with-zlib \ --with-curl \ --with-ldap \ --with-imap \ --with-kerberos \ --with-imap-ssl \ --with-gettext \ --with-gd \ --enable-gd-native-ttf \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-openssl \ --with-iconv \ --with-pcre-dir \ --with-mhash \ --with-mcrypt \ --with-xmlrpc \ --with-imap \ --enable-xml \ --enable-ftp \ --enable-mbstring \ --enable-soap \ --enable-sockets \ --enable-zip \ --disable-debug \ --enable-calendar \ --enable-static \ --enable-inline-optimization \ --enable-wddx \ --enable-opcache \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-pcntl \ --without-pear \ --enable-ctype
make && make install
#編輯httpd.conf 在 LoadModule php5_module modules/libphp5.so #下加入讓apache能夠識別php文件 AddType application/x-httpd-php .php .html .htm
編譯PHP經常使用的參數的解釋
--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 #用來指定 php3.ini 或 php4.ini 的路徑 --with-MySQL=/usr/local/mysql #mysql安裝目錄,對mysql的支持 --with-mysqli=/usr/local/mysql/bin/mysql_config #mysqli擴展技術不只能夠調用MySQL的存儲過程、處理MySQL事務,並且還可使訪問數據庫工做變得更加穩定。 --with-mysql-sock=/tmp/mysql.sock #指定mysql套接字文件位置 --enable-safe-mode #打開安全模式,默認值是打開的 --disable-short-tags #配置本選項後,PHP 的程序就不能使用短的標記,必定要用的長標記 --with-exec-dir=DIR #PHP 執行路徑(有時爲了系統的安全性考慮,會指定 PHP 程序必定要在哪一個目錄執行) --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-sqlite-utf8 #使sqllite支持utf-8 --enable-bcmath #打開圖片大小調整,用到zabbix監控的時候用到了這個模塊 --enable-sockets #打開 sockets 支持 --enable-exif #圖片的元數據支持 --enable-magic-quotes #魔術引用的支持 --disable-rpath #關閉額外的運行庫文件 --disable-debug #關閉調試模式 --enable-debug #本選項通常不會使用,除非在開發 PHP 程序時比較有用。它能夠顯示額外的錯誤信息 --with-ldap=DIR #若要使用目錄協議 (Lightweight Directory Access Protocol, LDAP) 則必需要打開本選項。有關 LDAP 的細節,能夠參考 RFC 文件的 RFC1777 及 RFC1778 --with-mime-magic=/usr/share/file/magic.mime #魔術頭文件位置 --with-apache=DIR #用本選項可讓 PHP 以apache的模塊方式使用,DIR 的字符串能夠是 /usr/local/apache 或其它安裝apache的目錄 --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-oracle=DIR #使用 Oracle 數據庫。Oracle 的版本要在 7.3 版以上。您也能夠在 PHP 程序中使用環境變量 ORACLE_HOME 來指定 Oracle 的路徑。更多有關 Oracle 的信息請參考 Oracle 的網站 http://www.oracle.com --with-sybase=DIR #使用 Sybase 數據庫。更多有關 Sybase 的信息請參考 Sybase 的網站 http://www.sybase.com --with-sybase-ct=DIR #使用 Sybase-CT 數據庫
CGI方式安裝經常使用的參數:
--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庫。
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自身去管理多進程,有點相似一個後端代理。不管什麼模式,在發佈產品服務器,都應該作進程和線程調優,作足夠多的性能及壓力方面的測試,找出最好的進程數組合。
選好一種PHP OPCode cache的擴展,這個也是很重要的,linux 2.6核心下,fcgi下,xcache有較好的實踐經驗,其餘的在併發數增長之後,性能衰減嚴重。若是真的想體驗,寧肯編譯多幾個PHP版本,也不要針對一個版本的PHP集合各類擴展,適應各類環境,這會讓把你本身逼進窘境的。