IT猫扑网文章教程

分类分类

linux下apache配置文件详解

2015-06-28 00:00作者:网管联盟

  ### Section 1: Global Environment
  //当服务器响应主机头(header)信息时显示Apache的版本和操作系统名称
  ServerTokens OS
  //设置服务器的根目录
  ServerRoot &/etc/httpd&
  
  #ScoreBoardFile run/httpd.scoreboard
  
  //设置运行Apache时使用的PidFile的路径
  PidFile run/httpd.pid
  
  //若300秒后没有收到或送出任何数据就切断该连接
  Timeout 300
  
  //不使用保持连接的功能,即客户一次请求连接只能响应一个文件
  /建议用户将此参数的值设置为On,即允许使用保持连接的功能
  KeepAlive Off
  
  //在使用保持连接功能时,设置客户一次请求连接能响应文件的最大上限
  MaxKeepAliveRequests 100
  
  //在使用保持连接功能时,两个相邻的连接的时间间隔超过15秒,就切断连接
  KeepAliveTimeout 15
  
  ##
  ## Server-Pool Size Regulation (MPM specific)
  ##
  # prefork MPM
  # StartServers: number of server processes to start
  # MinSpareServers: minimum number of server processes which are kept spare
  # MaxSpareServers: maximum number of server processes which are kept spare
  # MaxClients: maximum number of server processes allowed to start
  # MaxRequestsPerChild: maximum number of requests a server process serves
  //设置使用Prefork MPM运行方式的参数,此运行方式是Red hat默认的方式
  <IfModule prefork.c>
  
  //设置服务器启动时运行的进程数
  StartServers 8
  
  //Apache在运行时会根据负载的轻重自动调整空闲子进程的数目
  //若存在低于5个空闲子进程,就创建一个新的子进程准备为客户提供服务
  MinSpareServers 5
  
  //若存在高于20个空闲子进程,就创建逐一删除子进程来提高系统性能
  MaxSpareServers 20
  
  //限制同一时间的连接数不能超过150
  MaxClients 150
  
  //限制每个子进程在结束处理请求之前能处理的连接请求为1000
  MaxRequestsPerChild 1000
  </IfModule>
  
  # worker MPM
  # StartServers: initial number of server processes to start
  //设置使用Worker MPM运行方式的参数
  <IfModule worker.c>
  StartServers 2
  MaxClients 150
  MinSpareThreads 25
  MaxSpareThreads 75
  ThreadsPerChild 25
  MaxRequestsPerChild 0
  </IfModule>
  
  # perchild MPM
  # NumServers: constant number of server processes
  //设置使用perchild MPM运行方式的参数
  <IfModule perchild.c>
  NumServers 5
  StartThreads 5
  MinSpareThreads 5
  MaxSpareThreads 10
  MaxThreadsPerChild 20
  MaxRequestsPerChild 0
  </IfModule>
  
  //设置服务器的监听端口
  #Listen 12.34.56.78:80
  Listen 202.112.85.101:80
  
  #
  # Load config files from the config directory &/etc/httpd/conf.d&.
  //将/etc/httpd/conf.d目录下所有以conf结尾的配置文件包含进来
  Include conf.dpublic_html>
  # AllowOverride FileInfo AuthConfig Limit
  # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
  # <Limit GET POST OPTIONS>
  # Order allow,deny
  # Allow from all
  # </Limit>
  # <LimitExcept GET POST OPTIONS>
  # Order deny,allow
  # Deny from all
  # </LimitExcept>
  #</Directory>
  
  //当访问服务器时,依次查找页面Index.html index.htm.var
  DirectoryIndex index.html index.html.var
  
  //指定保护目录配置文件的名称
  AccessFileName .htaccess
  
  //拒绝访问以.ht开头的文件,即保证.htaccess不被访问
  <Files ~ &^.ht&>
  Order allow,deny
  Deny from all
  </Files>
  
  //指定负责处理MIME对应格式的配置文件的存放位置
  TypesConfig /etc/mime.types
  //指定默认的MIME文件类型为纯文本或HTML文件
  DefaultType text/plain
  
  //当mod_mime_magic.c模块被加载时,指定magic信息码配置文件的存放位置
  <IfModule mod_mime_magic.c>
  # MIMEMagicFile /usr/share/magic.mime
  MIMEMagicFile conf/magic
  </IfModule>
  
  //只记录连接Apache服务器的Ip地址,而不纪录主机名
  HostnameLookups Off
  //指定错误日志存放位置
  ErrorLog logs/error_log
  //指定记录的错误信息的详细等级为warn等级
  LogLevel warn
  //定义四中记录日志的格式
  LogFormat &%h %l %u %t &%r& %>s %b &%{ Referer }i& &%{ User-Agent }i&& combined
  LogFormat &%h %l %u %t &%r& %>s %b& common
  LogFormat &%{ Referer }i -> %U& referer
  LogFormat &%{ User-agent }i& agent
  
  //指定访问日志的纪录格式为combined(混合型),并指定访问日志存放位置
  # CustomLog logs/access_log common
  CustomLog logs/access_log combined
  #CustomLog logs/referer_log referer
  #CustomLog logs/agent_log agent
  #CustomLog logs/access_log combined
  
  //设置apache自己产生的页面中使用apache服务器版本的签名
  ServerSignature On
  
  //设置内容协商目录的访问别名
  Alias /icons/ &/var/www/icons/&
  //设置/var/www/icons/的访问权限
  <Directory &/var/www/icons&>
  //MultiViews 使用内容协商功决定被发送的网页的性质
  Options Indexes MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
  </Directory>
  
  //设置网页邮件服务
  Alias /webmail &/usr/share/squirrelmail&
  
  <Directory &/usr/share/squirrelmail&>
  Options Indexes MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
  </Directory>

#p#副标题#e#

  //设置apache手册的访问别名
  Alias /manual &/var/www/manual&
  
  <Directory &/var/www/manual&>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
  </Directory>
  //设置浏览器匹配
  BrowserMatch &Mozilla/2″ nokeepalive
  BrowserMatch &MSIE 4.0b2;& nokeepalive downgrade-1.0 force-response-1.0
  BrowserMatch &RealPlayer 4.0″ force-response-1.0
  BrowserMatch &Java/1.0″ force-response-1.0
  BrowserMatch &JDK/1.0″ force-response-1.0
  BrowserMatch &Microsoft Data Access Internet Publishing Provider& redirect-carefully
  BrowserMatch &^WebDrive& redirect-carefully
  
  #
  # Allow server status reports, with the URL of http://servername/server-s
  # Change the &.your-domain.com& to match your domain to enable.
  #
  #<Location /server-status>
  # SetHandler server-status
  # Order deny,allow
  # Deny from all
  # Allow from .your-domain.com
  #</Location>
  
  #
  # Allow remote server configuration reports, with the URL of
  # http://servername/server-i… (requires that mod_info.c be loaded).
  # Change the &.your-domain.com& to match your domain to enable.

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消