快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

apache主配置文件(配置解说)


  作者:汤海京
  
  Apache为网络管理员提供了丰富多彩的功能,包括目录索引、目录别名、内容协商、可配置的HTTP错误报告、CGI程序的SetUID执行、子进程资源管理、服务器端图象映射、重写URL、URL拼写检查以及联机手册man等。也就是说,如果您在Linux Server上成功安装配置了Apache之后,您的计算机也将随着Apache的生效而摇身一变,成为一台名副其实的Web Server,这种变化的确是激动人心的。
  
  在Internet时代,外部主页的发布已经成为树立公司形象的一个重要手段,而内部主页也成为公司管理的主要方式。但是,要想实现这些功能,首先应该把我们的Linux Server配置成为一台强大的Web Server。本章将详细介绍如何配置Apache服务器。希望各位同仁能够通过阅读本片文章达到理论实践双丰收的目的,在很短的时间里迅速成为一名出色的网络管理员。
  
  1.2 所需资源
  1.2.1 所需包
  RedHat6.2 服务器安装
  
  1.2.2 所需配置文件
  /etc/httpd/conf/httpd.conf 系统自带,管理员配置
  /etc/httpd/conf/access.conf 系统自带,不需要修改
  /etc/httpd/conf/srm.conf 系统自带,不需要修改
  
  1.3 配置方案
  /etc/httpd/conf/httpd.conf
  说明:apache主配置文件
  源文件:
  
  ServerType standalone
     #定义WebServer的启动方式为standalone,以增强其对大量访问的及时响应性
  ServerRoot "/etc/httpd"
     #指定包含httpd服务器文件的目录
  LockFile /var/lock/httpd.lock
  PidFile /var/run/httpd.pid
  ScoreBoardFile /var/run/httpd.scoreboard
  Timeout 300
     #响应超时量,单位为秒
  KeepAlive On
     #允许用户建立永久连接
  MaxKeepAliveRequests 100
  KeepAliveTimeout 15
  MinSpareServers 5
     #要保留的空闲服务器进程的最小值
  MaxSpareServers 20
     #要保留的空闲服务器进程的最大值
  StartServers 8
     #系统启动时的守护进程数
  MaxClients 150
     #所能提供服务的最大客户端编号,大于它的部分被放入请求队列
  MaxRequestsPerChild 100
  LoadModule vhost_alias_module modules/mod_vhost_alias.so
  LoadModule env_module     modules/mod_env.so
  LoadModule config_log_module modules/mod_log_config.so
  LoadModule agent_log_module  modules/mod_log_agent.so
  LoadModule referer_log_module modules/mod_log_referer.so
  LoadModule mime_module    modules/mod_mime.so
  LoadModule negotiation_module modules/mod_negotiation.so
  LoadModule status_module   modules/mod_status.so
  LoadModule info_module    modules/mod_info.so
  LoadModule includes_module  modules/mod_include.so
  LoadModule autoindex_module  modules/mod_autoindex.so
  LoadModule dir_module     modules/mod_dir.so
  LoadModule cgi_module     modules/mod_cgi.so
  LoadModule asis_module    modules/mod_asis.so
  LoadModule imap_module    modules/mod_imap.so
  LoadModule action_module   modules/mod_actions.so
  LoadModule userdir_module   modules/mod_userdir.so
  LoadModule alias_module    modules/mod_alias.so
  LoadModule rewrite_module   modules/mod_rewrite.so
  LoadModule access_module   modules/mod_access.so
  LoadModule auth_module    modules/mod_auth.so
  LoadModule anon_auth_module  modules/mod_auth_anon.so
  LoadModule db_auth_module   modules/mod_auth_db.so
  LoadModule digest_module   modules/mod_digest.so
  LoadModule proxy_module    modules/libproxy.so
  LoadModule expires_module   modules/mod_expires.so
  LoadModule headers_module   modules/mod_headers.so
  LoadModule usertrack_module  modules/mod_usertrack.so
  LoadModule setenvif_module  modules/mod_setenvif.so
  LoadModule perl_module    modules/libperl.so
  LoadModule php3_module    modules/libphp3.so
  ClearmoduleList
  AddModule mod_vhost_alias.c
  AddModule mod_env.c
  AddModule mod_log_config.c
  AddModule mod_log_agent.c
  AddModule mod_log_referer.c
  AddModule mod_mime.c
  AddModule mod_negotiation.c
  AddModule mod_status.c
  AddModule mod_info.c
  AddModule mod_include.c
  AddModule mod_autoindex.c
  AddModule mod_dir.c
  AddModule mod_cgi.c
  AddModule mod_asis.c
  AddModule mod_imap.c
  AddModule mod_actions.c
  #AddModule mod_speling.c
  AddModule mod_userdir.c
  AddModule mod_alias.c
  AddModule mod_rewrite.c
  AddModule mod_access.c
  AddModule mod_auth.c
  AddModule mod_auth_anon.c
  AddModule mod_auth_db.c
  AddModule mod_digest.c
  AddModule mod_proxy.c
  AddModule mod_expires.c
  AddModule mod_headers.c
  AddModule mod_usertrack.c
  AddModule mod_so.c
  AddModule mod_setenvif.c
  AddModule mod_perl.c
  AddModule mod_php3.c
  Port 80
     #定义服务器所使用的TCP的端口号
  User nobody
  Group nobody
     #以上两行是分配给httpd的新用户的文件权限,出于安全的考虑把
     它们的权限设置成为最低。
  ServerAdmin [email protected]
     #设置Web管理员的邮件地址
  ServerName WebOA
     #定义客户端从服务器读取数据时返回给客户端的主机名,其缺省值
     是localhost,第一次安装Linux的时候经常这里出错。
  DocumentRoot "/home/weboa/jakarta-tomcat/webapps/weboa"
     #设置所有Apache文档的根目录,比如说,用户对
     http://www.weboa.com.cn/index.html的访问请求,Apache对它
     的响应是/home/weboa/jakarta-tomcat/webapps/weboa/index.html
  
     Options FollowSymLinks
     AllowOverride None
  
     Options Indexes Includes FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from all      # 允许所有人访问
  
  UserDir public_html
  DirectoryIndex index.html index.htm index.shtml index.cgi
     #设置多种成功访问主页的方式,为的是提高系统的容错性
  AccessFileName .htaccess
  
     Order allow,deny
     Deny from all
  
  UseCanonicalName On
  TypesConfig /etc/mime.types
  DefaultType text/plain
  
     MIMEMagicFile share/magic
  
  HostnameLookups Off
  ErrorLog /usr/httpd/log/error_log
  LogLevel warn
     #定义那些错误类型被记录到错误日志中
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
     #所有的LogFormat都用来定义日志中的条目
  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  LogFormat "%{Referer}i -> %U" referer
  LogFormat "%{User-agent}i" agent
  CustomLog /usr/httpd/log/access_log common
  ServerSignature On
  Alias /icons/ "/home/httpd/icons/"
  #定义虚拟主机目录与系统目录的对应关系
  
     Options Indexes MultiViews
     AllowOverride None
     Order allow,deny
     Allow from all
  
  ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"
  #定义CGI目录
  
     AllowOverride None
     Options ExecCGI
     Order allow,deny
     Allow from all
  
  IndexOptions FancyIndexing
  AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
  AddIconByType (TXT,/icons/text.gif) text/*
  AddIconByType (IMG,/icons/image2.gif) image/*
  AddIconByType (SND,/icons/sound2.gif) audio/*
  AddIconByType (VID,/icons/movie.gif) video/*
  AddIcon /icons/binary.gif .bin .exe
  AddIcon /icons/binhex.gif .hqx
  AddIcon /icons/tar.gif .tar
  AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
  AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
  AddIcon /icons/a.gif .ps .ai .eps
  AddIcon /icons/layout.gif .html .shtml .htm .pdf
  AddIcon /icons/text.gif .txt
  AddIcon /icons/c.gif .c
  AddIcon /icons/
顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论