1.)首先到apache官方網站 http://httpd.apache.org/download.cgi 下載最新版本的apache,本文的版本是httpd-2.4.3.tar.bz2(截至2015-6-4,官網最新版本httpd-2.4.12依然適用本文檔)。解壓安裝,執行以下命令: 正則表達式
./configure --prefix=/opt/httpd --enable-so apache
若出現下面的錯誤提示 函數
configure: error: APR not found. Please read the documentation. 性能
說明缺乏apr包,到apache官網下載http://apr.apache.org/download.cgi。 網站
2)安裝apr很簡單,默認路徑就能夠 ui
./configure;make;make install 操作系統
默認安裝到了/usr/local/apr,安裝完成後,把apr的lib庫路徑放到系統庫環境變量能夠找到的位置,編劇/etc/ld.so.conf文件,添加/usr/local/apr/lib,保存後執行ldconfig使之生效。 .net
注意:若系統提示錯誤「rm: cannot remove `libtoolT': No such file or directory」,解決辦法多是系統中的automake沒有正確安裝,使用yum install automake* 安裝後就沒問題了。這一點不少人找不到緣由,我這裏給出辦法或許能夠幫助大家。 接口
APR介紹:APR(Apache portable Run-time libraries,Apache可移植運行庫),其功能主要爲上層的應用程序提供一個能夠跨越多操做系統平臺使用的底層支持接口庫。 ip
3)繼續回來編譯apache,執行 ./configure --prefix=/opt/httpd --enable-so
出現這個錯誤提示 configure: error: APR-util not found. Please read the documentation。這個錯誤說明缺乏apr-util軟件包。
4)下載編譯apr-util以後,安裝apr-util
./configure --with-apr=/usr/local/apr
make;make install
5)繼續安裝apache,提示下面的錯誤
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/,說明缺乏pcre軟件包,從http://sourceforge.net/projects/pcre/ 下載並編譯安裝
./configure --prefix=/usr/local/pcre;make;make install
PCRE介紹:(Perl Compatible Regular Expressions 即 Perl語言兼容的正則表達式)是一個用C語言編寫的正則表達式函數庫,由菲利普.海澤(Philip Hazel)編寫。PCRE是一個輕量級的函數庫,比Boost之類的正則表達式庫小得多。PCRE十分易用,同時功能也很強大,性能超過了POSIX正則表達式庫和一些經典的正則表達式庫
6)繼續安裝apache,
./configure --prefix=/opt/httpd --enable-so
接下來很順利的編譯經過。apache安裝所有完成。
注意:若系統中存在多個版本的apr,且安裝默認找到的版本較舊,能夠使用參數--with-apr=/usr/local/apr來明確用新版本的apr。
最後,給出 httpd-2.4.12的編譯命令
指明使用apr,apr-util,pcre,mpm工做模式的編譯命令以下:
./configure --prefix=/opt/httpd2.4.12 --with-mpm=worker --with-apr=/usr/local/apr --with-pcre=/usr/local/pcre --with-apr-util=/usr/local/apr-util