AddOutputFilterByType DEFLATEtext/html text/plain text/xml text/css text/javascript AddOutputFilterByType DEFLATEapplication/ms* application/vnd* application/postscript application/javascriptapplication/x-javascript SetEnvIf User-Agent ^Mozilla/4 gzip-only-text/html SetEnvIf User-Agent ^Mozilla/4/.0[678]no-gzip SetEnvIf User-Agent \bMSIE !no-gzip SetEnvIf User-Agent \bMSIE!gzip-only-text/html # SetEnvIfNoCase Request_URI/.(gif|jpg|cab|jpe?g|exe|bmp|mp3|rar|zip|swf|png)$ no-gzip dont-vary DeflateCompressionLevel 9 </IfModule> 6、 Apache的status监控时默认地址的修改 Apache中的默认设置为 <Location /server-status> SetHandler server-status Order deny,allow # Deny from all Allow from .localhost </Location> 此种设置不安全,如果启用status监控需要修改默认地址,若启动虚拟主机,则在每个虚拟主机节点中进行配置,方有效,即在 <VirtualHost *:80> <Location /test-server-status> SetHandler server-status Order deny,allow # Deny from all Allow from .localhost </Location> </VirtualHost > 之间配置 若无虚拟主机则正常配置 <Location /test-server-status> SetHandler server-status Order deny,allow # Deny from all Allow from .localhost </Location> 将server-status的默认值需要修改一下,避免此处的安全漏洞 注:若要启动扩展状态监控 即 配置 ExtendedStatus On 注意: ExtendedStatus On不能配置在单独的虚拟主机节点内,需要在httpd.conf中配置 可参考: httpd-info.conf文件中的配置
7、 Apache的虚拟主机配置 NameVirtualHost *:80 <VirtualHost *:80> ServerName www.test.cn ServerAlias www.test.edu.cn DocumentRoot /test/www AddDefaultCharset Off <Directory"/test/www"> Options-Indexes AllowOverride None Orderallow,deny Allow fromall </Directory> ErrorDocument404 /404.html ErrorDocument403 /403.html </VirtualHost> 虚拟主机按以上进行配置,对于新版本的apache注意将 # Virtual hosts #Include conf/extra/httpd-vhosts.conf 处进行修改 Includeconf/extra/httpd-vhosts.conf 在httpd-vhosts.conf文件中进行虚拟主机的配置 8、 Apache默认线程数调整 对2.2版本的apache,在httpd.conf文件中将 # Include conf/extra/ httpd-mpm.conf修改为 Include conf/extra/ httpd-mpm.conf 并在此文件中寻找到此处 # WinNT MPM # ThreadsPerChild:constant number of worker threads in the server process #MaxRequestsPerChild: maximum number ofrequests a server process serves <IfModulempm_winnt_module> ThreadLimit 2000 ThreadsPerChild 2000 MaxRequestsPerChild 100 </IfModule> 此处是将线程的限制修改到2000,注意window修改2000的限制在window下会报一些错误,因为window下默认达不到2000,一般只能到1912左右,要想突破2000的限制,需要使用ThreadLimit指令 Linux下需要对以下模块设置,linux下Apache默认工作模式是prefork 可通过 ./apachectl –l来查看apache的工作模式 Window下通过 httpd.exe –l来查看 注:需要在apache的安装目录下的bin目录中 # prefork MPM # StartServers: number of server processesto start # MinSpareServers: minimum number of serverprocesses which are kept spare # MaxSpareServers: maximum number of serverprocesses which are kept spare # MaxClients: maximum number of serverprocesses allowed to start # MaxRequestsPerChild: maximum number ofrequests a server process serves <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0 </IfModule> Linux下若调整线程数则调整以上数字,重点调整MaxClients 配置样例,需要根据机器的配置进行调整: <IfModulempm_prefork_module> StartServers 10 MinSpareServers 10 MaxSpareServers 20 MaxClients 1500 MaxRequestsPerChild 10000 </IfModule>