Apache 配置文件详解

发布时间:2008年04月02日      浏览次数:1468 次
//设置apache服务器根的访问权限
<Directory />
//允许符号链接跟随,访问不在本目录下的文件
Options FollowSymLinks
//禁止读取.htaccess配置文件的内容
AllowOverride None
</Directory>
//设置根文档目录的访问权限
<Directory "/home/httpd">
//Indexes:当在目录中找不到DirectoryIndex列表中指定的文件
//就生成当前目录的文件列表
//FollowSymLinks允许符号链接跟随,访问不在本目录下的文件
Options Indexes FollowSymLinks
//禁止读取.htaccess配置文件的内容
AllowOverride None
//指定先执行Allow(允许)访问规则,在执行Deny访问规则
Order allow,deny
# Allow from 202.112.85.0/16
//设置Allow(允许)访问规则,允许所有连接
Allow from all
# Deny from all
</Directory>
//对Apache服务器的根的访问不生成目录列表,同时指定错误输出页面
<LocationMatch "^/$>
Options -Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>
//不允许每用户的服务器配置
<IfModule mod_userdir.c>
//不允许每用户的服务器配置
UserDir disable
#//基于安全考虑,禁止root用户使用自己的个人站点
#UserDir disable root
#//配置对每个用户web站点目录的设置
#UserDir public_html
</IfModule>
//设置对每个用户web站点目录的访问权限
#<Directory /home/*/public_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>
//设置apache手册的访问别名
Alias /manual "/var/www/manual"
<Directory "/var/www/manual">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
(2)
//重定向连接
# Redirect permanent /foo http://www.example.com/bar
//设置自动生成目录列表的显示方式
//FancyIndexing 对每种类型的文件前加上一个小图标以示区别
//VersionSort 对同一个软件的多个版本进行排序
//NameWidth=* 文件名字段自动适应当前目录下的最长文件名
IndexOptions FancyIndexing VersionSort NameWidth=*
//当使用IndexOptions FancyIndexing之后,配置下面的参数
//用于告知服务器在遇到不同的文件类型或扩展名时采用MIME编码格式
//辨别文件类型并显示相应的图标
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/*
//当使用IndexOptions FancyIndexing之后,配置下面的参数
//用于告知服务器在遇到不同的文件类型或扩展名时采用所指定的格式
//并显示相应的图标
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/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
//当使用IndexOptions FancyIndexing之后,且无法识别文件类型时
//显示此处定义的图标
DefaultIcon /icons/unknown.gif
#
# AddDescription allows you to place a short description after a file in
# server-generated indexes. These are only displayed for FancyIndexed
# directories.
# Format: AddDescription "description" filename
#
#AddDescription "GZIP compressed document" .gz
#AddDescription "tar archive" .tar
#AddDescription "GZIP compressed tar archive" .tgz
//当服务器自动列出目录列表时,在所生成的页面之后显示readme.html的内容
ReadmeName README.html
//当服务器自动列出目录列表时,在所生成的页面之前显示header.html的内容
HeaderName HEADER.html
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!