apache2.0重要日程
2.0a1 Mar 2000 首次推出第一版本 The first Apache 2.0 alpha was launched at the final session of the ApacheCon 2000 conference. A number of ASF members on stage updated the website and copied the distribution files into the correct locations live of in front of the audience. Announcements were then sent to a number of key sites such as Slashdot and Freshmeat. Coverage in Apache Week issue 190
2.0.11 Feb 2001 首次推出发行版本 This was the first version to use a new release procedure, where the tree would be tagged and depending on the outcome of testing would later be distributed as a alpha, beta, or stable release. An early prototype of SSL support by Ben Laurie was added (Apache Week issue 235) as was a port of mod_proxy to Apache 2.0
2.0.16 Apr 2001 首次推出第二版本 First beta release
2.0.35 Apr 2002 First General Availability release
2.0.36 May 2002 首次推出第二个稳定发行版本 Second stable release
2.0.52 September 2004 稳定发行版本的最新版本 Security fix release correcting a new issue introduced in 2.0.51
之所以在要这里列出apache2.0发展的一些重要日期,是为了说明apache2.0已经在两年前就有了稳字版本,两年以来,一直在修补漏洞,
其功能上已经保持稳定;所以是否有必要把apace1.3升级为apache2.0,我认为是可以考虑的,并且是可行的。
并且apache2应该会成为将来使用的趋势
并且网络上已经有重大的网络服务商在使用apache2.0,我将在下面列举例子来说明。
另外apache小组刚刚推出了有新增模块功能的apache2.1/2.2版本。请参考http://httpd.apache.org/docs-2.1/
以安装apache2.0.52时为参考
apache2.0重要日程
2.0a1 Mar 2000 首次推出第一版本 The first Apache 2.0 alpha was launched at the final session of the ApacheCon 2000 conference. A number of ASF members on stage updated the website and copied the distribution files into the correct locations live of in front of the audience. Announcements were then sent to a number of key sites such as Slashdot and Freshmeat. Coverage in Apache Week issue 190
2.0.11 Feb 2001 首次推出发行版本 This was the first version to use a new release procedure, where the tree would be tagged and depending on the outcome of testing would later be distributed as a alpha, beta, or stable release. An early prototype of SSL support by Ben Laurie was added (Apache Week issue 235) as was a port of mod_proxy to Apache 2.0
2.0.16 Apr 2001 首次推出第二版本 First beta release
2.0.35 Apr 2002 First General Availability release
2.0.36 May 2002 首次推出第二个稳定发行版本 Second stable release
2.0.52 September 2004 稳定发行版本的最新版本 Security fix release correcting a new issue introduced in 2.0.51
之所以在要这里列出apache2.0发展的一些重要日期,是为了说明apache2.0已经在两年前就有了稳字版本,两年以来,一直在修补漏洞,
其功能上已经保持稳定;所以是否有必要把apace1.3升级为apache2.0,我认为是可以考虑的,并且是可行的。
并且apache2应该会成为将来使用的趋势
并且网络上已经有重大的网络服务商在使用apache2.0,我将在下面列举例子来说明。
另外apache小组刚刚推出了有新增模块功能的apache2.1/2.2版本。请参考http://httpd.apache.org/docs-2.1/
以安装apache2.0.52时为参考
第一部分:直接启用压缩
针对live.xxxxx.com要使用压缩这一特殊技术,
可以不用修改源代码了,只要是下载的源代码就可以直接使用
第一步 安装配置
a)./configure 配置,采用worker多线程工作模式,并开启mod_deflate
一定要有--enable-deflate 和 --with-mpm=worker选项. 如下是安装命令,供参考
./configure --prefix=/www --enable-so --enable-deflate --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-suexec --enable-mods-shared=all --with-mpm=worker
b) make;make install
第二步 http.conf 配置
http.conf主要有以下几点要注意
0)配置worker工作模式
apache2.0有两种工作模式,prefork模式实际就是apache1.3的工作模式。而我们在安装apache2.0.52中使用worker
典型配置如下
ServerLimit 35 //最多可以启动35个进程
ThreadLimit 200 //每个进程最多可以启动200个线程
StartServers 5 //启动apache时,首次启动5个进程
MaxClients 2400 //最多支持2400个并发的http链接
MinSpareThreads 100 //最少有100个线程空闲,否则新增加进程或者线程了
MaxSpareThreads 200 //最多有200个线程空闲,否则就要自动回收多余空闲的线程或者进程
ThreadsPerChild 80 //启动一个进程时,此进程首先启动80个线程
MaxRequestsPerChild 0 //允许每个进程在它的生命周期内处理的http最大请求. 0没有限制。 Limit on the number of requests that an individual child server will handle during its life. If MaxRequestsPerChild is 0, then the process will never expire.
(这里我遇到一些怪问题,ServerLimit和ThreadLimit必须加在前两行,否则就以源代码的限制为准)
其中ThreadLimit指令值一定要大于ThreadsPerChild, 且ServerLimit*ThreadsPerChild的值一定要大于MaxClients
详细指令或参考其它资料
1) 启动deflate模块
则必须LoadModule deflate_module modules/mod_deflate.so
然后在所有的LoadModule之后加入以下指令
#############################the following configuration is about mod_deflate############
DeflateFilterNote ratio
DeflateBufferSize 6596
LogFormat '"%h %l %u %t "%r" %>s %b' deflate
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI
.(?:gif|jpe?g|png|js|css)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
#############################configure mod_deflate End ############
其中以上指令当中.(?:gif|jpe?g|png|js|css|swf|bmp)$ no-gzip dont-vary 这里面表示除gif|jpe?g|png|js|css|swf|bmp类型的文件不进行压缩之外,
xml/html/htm类型的文件都可以进行压缩。
DeflateBufferSize 6596 这个指令中6596这个值是可以进行修改的。但暂时就使用这个值。
关于mod_deflate,详细请参考http://httpd.apache.org/docs-2.0/mod/mod_deflate.html
2) 配置多域名
a)使用NameVirtualHost指令,如下
NameVirtualHost *:80
b)VirtualHost指令,如下作参考
ServerAdmin webmaster@mail.xxxxxx.com
DocumentRoot /www/webdev/html/live
ServerName live.test.com
SetEnvIf Request_URI "\.xml$" dontlog
CustomLog /logs/live130_access deflate
DirectoryIndex index.html index.php index2.html
order allow,deny
allow from all
3) 字体 指令 AddDefaultCharset Off
4) Listen指令 记得配置上
5) 关于log的格式,你们自己再修改吧
第二部分,只对某些频繁被访问的文件,在特定条件下,采用重定向到压缩
1.启用rewrite模块
LoadModule rewrite_module modules/mod_rewrite.so
#if request url is loop_chance.xml then set three env avariables.
SetEnvIf Request_URI loop_chance.xml HAVE_MyRequestHeader=0 HAVE_MyRequestHeaderG=0 HAVE_MyRequestHeaderI=0
#only those browser can receive gzip content whose Accept-Encoding header have contained gzip
SetEnvIf Accept-Encoding gzip HAVE_MyRequestHeaderG=1
SetEnvIf HAVE_MyRequestHeaderG 0 HAVE_MyRequestHeader=1
#only MSIE browser will be sent gzip content
BrowserMatch \bMSIE HAVE_MyRequestHeaderI=1
SetEnvIf HAVE_MyRequestHeaderI 0 HAVE_MyRequestHeader=1
#env avarialbe value will be set to 1 without init,so here HAVE_MyRequestHeader_gzip=1
SetEnvIf HAVE_MyRequestHeader 0 HAVE_MyRequestHeader_gzip
Header add Content-Encoding gzip env=HAVE_MyRequestHeader_gzip
LogFormat '"%D %h %l %u %t "%r" %>s %b' deflate
2.虚拟主机配置
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/live
DirectoryIndex index.htm index.html
AddHandler cgi-script .cgi .pl
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
RewriteEngine On
RewriteCond % 1
# RewriteCond % \bMSIE
RewriteRule /data/loop_chance.xml /data/loop_chancegz.xml
ServerName live.xxxxxx.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/live.log deflate
3) 字体 指令 AddDefaultCharset Off
4) Listen指令 记得配置上 如Listen 0.0.0.0:80,或者指定ip地址
5) 关于log的格式,你们自己再修改吧