*此为用yum安装的apache文件的各项解释和编译安装后的apache配置文件大同小异,仅做参考
httpd 的配置文件是: /etc/httpd/conf/httpd.conf 【 //查看配置文件 # grep -v "#" /etc/httpd/conf/httpd.conf //当服务器响应主机头(header)信息时显示Apache 的版本和操作系统名称 ServerTokens OS //设置服务器的根目录 ServerRoot "/etc/httpd" //设置运行Apache 时使用的PidFile 的路径 PidFile run/httpd.pid //若300 秒后没有收到或送出任何数据就切断该连接 Timeout 300 //不使用保持连接的功能,即客户一次请求连接只能响应一个文件 /建议用户将此参数的值设置为On,即允许使用保持连接的功能 KeepAlive Off //在使用保持连接功能时,设置客户一次请求连接能响应文件的最大上限 MaxKeepAliveRequests 100 //在使用保持连接功能时,两个相邻的连接的时间间隔超过15 秒,就切断连接 KeepAliveTimeout 15 //设置使用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 运行方式的参数 <IfModule worker.c> ………… </IfModule> //设置使用perchild MPM 运行方式的参数 <IfModule perchild.c> ………… </IfModule> //设置服务器的监听端口 Listen 80 //将/etc/httpd/conf.d 目录下的所有以conf 结尾的配置文件包含进来 Include conf.d/*.conf //动态加载模块(DSO) LoadModule access_module modules/mod_access.so LoadModule auth_module modules/mod_auth.so ……………………………… LoadModule proxy_connect_modulemodules/mod_proxy_connect.so //当使用内置模块prefork.c 时动态加载cgi_module <IfModule prefork.c> LoadModule cgi_module modules/mod_cgi.so </IfModule> //当使用内置模块worker.c 时动态加载cgid_module <IfModule worker.c> LoadModule cgid_module modules/mod_cgid.so </IfModule> //设置运行Apache 服务器的用户和组 User apache Group apache //设置Apache 服务器管理员的E-mail 地址 ServerAdmin root@localhost //关闭此选项,当Apache 服务器需要指向本身的连接时使用 UseCanonicalName Off //设置根文档路径 DocumentRoot "/var/www/html" //设置Apache 服务器根的访问权限 <Directory /> //允许符号链接跟随,访问不在本目录下的文件 Options FollowSymLinks //禁止读取.htaccess 配置文件的内容 AllowOverride None </Directory> //设置根文档目录的访问权限 <Directory "/var/www/html"> //Indexes:当在目录中找不到DirectoryIndex 列表中指定的文件 // 就生成当前目录的文件列表 //FollowSymLinks:允许符号链接跟随,访问不在本目录下的文件 Options Indexes FollowSymLinks //禁止读取.htaccess 配置文件的内容 AllowOverride None //指定先执行Allow(允许)访问规则,再执行Deny(拒绝)访问规则 Order allow,deny //设置Allow(允许)访问规则,允许所有连接 Allow from all </Directory> //对Apache 服务器根的访问不生成目录列表,同时指定错误输出页面 <LocationMatch "^/$> Options -Indexes ErrorDocument 403 /error/noindex.html </LocationMatch> //不允许每用户的服务器配置 <IfModule mod_userdir.c> UserDir disable </IfModule> //当访问服务器时,依次查找页面index.html、index.html.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 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 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> //设置Apche 手册的访问别名 Alias /manual "/var/www/manual" //设置/var/www/manual 目录的访问权限 <Directory "/var/www/manual"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> //指定DAV 加锁数据库文件的存放位置 <IfModule mod_dav_fs.c> DAVLockDB /var/lib/dav/lockdb </IfModule> //设置CGI 目录的访问别名 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" //由于Red Hat 中不使用worker MPM 运行方式,所以不加载mod_cgid.c 模块 <IfModule mod_cgid.c> Scriptsock run/httpd.cgid </IfModule> //设置CGI 目录的访问权限 <Directory "/var/www/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> //设置自动生成目录列表的显示方式 // 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/blank.gif ^^BLANKICON^^ //当使用IndexOptions FancyIndexing 之后,且无法识别文件类型时 //显示此处定义的图标 DefaultIcon /icons/unknown.gif //当服务器自动列出目录列表时,在所生成的页面之后显示README.html 的内容 ReadmeName README.html //当服务器自动列出目录列表时,在所生成的页面之前显示HEADER.html 的内容 HeaderName HEADER.html //设置在线浏览用户可以实时解压缩.Z .gz .tgz 类型的文件 //并非所有浏览器都支持 AddEncoding x-compress Z AddEncoding x-gzip gz tgz //设置网页内容的语言种类(浏览器要启用内容协商) //对中文网页,此项无实际意义 AddLanguage da .dk ………… AddLanguage hr .hr //当启用内容协商时,设置语言的先后顺序 LanguagePriority en da nl et fr de el it ja kr no plpt pt-br ltz ca es sv tw // Prefer:当有多种语言可以匹配时,使用LanguagePriority 列表的第1 项 // Fallback:当没有语言可以匹配时,使用LanguagePriority 列表的第1 项 ForceLanguagePriority Prefer Fallback //设置默认字符集 AddDefaultCharset ISO-8859-1 //设置各种字符集 AddCharset ISO-8859-1 .iso8859-1 .latin1 …………………… AddCharset shift_jis .sjis //添加新的MIME 类型(避免用户编辑/etc/mime.types) AddType application/x-tar .tgz //设置Apache 对某些扩展名的处理方式 AddHandler imap-file map AddHandler type-map var //使用过滤器执行SSI AddOutputFilter INCLUDES .shtml //设置错误页面目录的别名 Alias /error/ "/var/www/error/" //设置/var/www/error 目录的访问权限 <IfModule mod_negotiation.c> <IfModule mod_include.c> <Directory "/var/www/error"> AllowOverride None Options IncludesNoExec AddOutputFilter Includes html AddHandler type-map var Order allow,deny Allow from all LanguagePriority en es de fr ForceLanguagePriority Prefer Fallback </Directory> //设置错误输出页面 ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var ……………… ErrorDocument 506/error/HTTP_VARIANT_ALSO_VARIES.html.var </IfModule> </IfModule> //设置浏览器匹配 BrowserMatch "Mozilla/2" nokeepalive BrowserMatch "MSIE 4\.0b2;" nokeepalivedowngrade-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 InternetPublishing Provider" redirect-carefully BrowserMatch "^WebDrive" redirect-carefully # 】 -介绍Apache服务器文件和目录: WEB站点目录 描述 /var/www Apache WEB站点文件的目录 /var/www/html WEB站点的WEB文件 /var/www/cgi-bin CGI程序文件 /var/www/html/manual Apache WEB服务器手册 /var/www/htmll/usage webalizer程序文件 配置文件 /etc/httpd/conf 基于目录的配置文件,.htaccess文件包含对它所在目录中文件的访问控制指令 /etc/httpd/conf/httpd.conf Apache WEB服务器配置文件目录 /etc/httpd/conf/srm.conf 主要的Apache WEB服务器配置文件 /etc/httpd/conf/access.conf 用来处理文档规范,配置文件类型昨未知的老式配置文件 启动脚本 /etc/rc.d/init.d/httpd WEB服务器守护进程的启动脚本 /etc/rc.d/rc3.d/S85httpd 将运行级目录(/etc/rc3.d)连接到目录/etc/rc.d/init.d中的启动脚本 应用文件 /usr/sbin Apache WEB服务器程序文件和应用程序的位置 /usr/doc/ Apache WEB服务器文档 /var/log/http Apache 日志文件的位置
|