作為最流行的Web服務(wù)器,Apache已經(jīng)很久沒有用重大更新來吸引用戶的目光了。2012年8月16日,Apache終于進(jìn)行了自2005年12月以來的首次重大更新,發(fā)布Apache HTTP Server 2.4.3。
Apache 2.4提供了很多性能方面的提升,包括支持更大流量、更好地支持云計(jì)、利用更少的內(nèi)存處理更多的并發(fā)等。除此之外,新版Apache的提升還包括性能提升、內(nèi)存利用、異步I/O的支持、動態(tài)反向代理設(shè)置、與時間驅(qū)動的Web服務(wù)器相當(dāng)或更好的性能、更強(qiáng)大的處理資源分配能力,更便捷的緩存支持以及可定制的高速服務(wù)器和代理等。其它的功能還包括更簡單的錯誤分析、更靈活的設(shè)置項(xiàng)、更強(qiáng)大的驗(yàn)證機(jī)制和更完整的文檔。
Apache 2.4的主要目標(biāo)之一是大幅改進(jìn)性能,在這款剛剛發(fā)布的Web服務(wù)器中,我們發(fā)現(xiàn)它也從競爭對手Nginx處借鑒了不少,增加了不少對高性能的支持。它對緩存、代理模塊、會話控制、異步讀寫支持等都進(jìn)行了改進(jìn)。
Apache服務(wù)器項(xiàng)目管理委員會和Apache基金會主席Jim Jagielski表示,他們希望終端用戶能真正地看到性能進(jìn)步,Apache 2.4比許多以速度見長的Web服務(wù)器更快,例如Nginx。
Apache 2.4.3安裝配置步驟如下:
1、安裝基礎(chǔ)包
yum install gcc gcc-c++ zlib zlib-devel openssl openssl-devel libtool -y
2、安裝apr
cd apr ./configure --prefix=/usr/local/apr/ && make && make install
3、安裝apr-util
cd ../apr-util ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ && make && make install
4、安裝pcre
cd pcre-8.20 ./configure --prefix=/usr/local/pcre && make && make install
5、安裝httpd 2.4.3
編譯必須把 apr,apr-util 的源文件放到 apache2.4.3 源碼的 srclib 目錄下,并修改 apr 源碼目錄為apr,apr-util 源碼目錄為 apr-util
cp -rf apr-1.4.6 ./httpd-2.4.3/srclib/apr cp -rf apr-util-1.5.1 ./httpd-2.4.3/srclib/apr-util cd httpd-2.4.3 ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-speling --enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-ssl --with-ssl=/usr/local/openssl/ --enable-rewrite --enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --with-included-apr make make install
可能出現(xiàn)的錯誤:make時出現(xiàn)server/.libs/libmain.a(exports.o):(.data+0xcfc): undefined reference to `apr_os_uuid_get’,解決辦法:
cd srclib/apr; make cd srclib/apr-util; make
再退回 apache 的源碼目錄重新 make
6、安裝Tomcat-connectors(mod_jk.so模塊)
tar zxvf tomcat-connectors-1.2.37-src.tar.gz cd tomcat-connectors-1.2.37-src/native/ ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-java-home=/usr/local/jdk make && make install
檢查/usr/local/apache2/modules下是否有mod_jk.so ,如果沒有就復(fù)制過去。
注意conf/httpd.conf文件中ServerName xxx.xxx.com:80需要改為ServerName 127.0.0.1:80,可以使用apactrl -t進(jìn)行語法分析
7、優(yōu)化Apache
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd #編輯此服務(wù),將前三行修改為
#!/bin/bash
# chkconfig: 35 85 15
# description:Apache httpd
service httpd restart
chkconfig --add httpd
chkconfig --level 35 httpd on 