1.这里就不分段了,一排写下去,都是httpd的配置信息,在/etc/httpd/conf/httpd.conf这个文档中
2.监听套接字
#Listen 12.34.56.78:80 Listen 80 #监听80端口 Listen 8080 #增加的监听8080端口 Listen 192.168.1.101:8080 #监听指定IP的8080端口
3.配置使用keep alive
连接一旦建立,只有超时或超过最大连接数才会断开,哪个先到达,以哪个为准
#KeepAlive Off KeepAlive On #关闭保持连接 MaxKeepAliveRequests 100 #最大连接数 KeepAliveTimeout 15 #连接超时时间
4.DSO模块加载方式
LoadModule module_name /path/to/module (可以使用绝对路径和相对路径,相对路径为ServerRoot定义的路径)
httpd -M: 列出已经装载的所有DSO及非DSO模块
httpd -l: 列出支持使用的非DSO模块
# Example: # LoadModule foo_module modules/mod_foo.so # LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule auth_digest_module modules/mod_auth_digest.so LoadModule authn_file_module modules/mod_authn_file.so ...
5.配置站点根目录
# DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/var/www/html"
6.配置页面访问属性
<Directory "/var/www/html"> Options #以下为选项,一般是写成一行,这里为了方便归类,写成竖排 Indexes #缺少主页时,允许将目录中的所有文件以列表的方式发回给用户,危险 FollowSymLinks #允许跟随符号连接所指向的原始文件,危险 none #所有都不启用 all #所有都启用 ExecCGI #允许使用mod_cgi模块执行CGI脚本 Includes #允许使用mod_include模块实现服务器端包含(SSI) MultiViews #允许使用mod_negotiation实现内容协商 SymLinksIfOwnerMatch #在链接文件属主属组与原始文件的属主属组相同时,允许跟随符号链接所指向的原始文件 AllowOverride #以下的是否禁用 None # 表示所有都不禁用 Option # FileInfo # AuthConfig #基于用户认证 Limit # Order allow,deny #最后的这两行都是基于IP的认证的, Allow from all #匹配规则:二者都匹配或者二者都无匹配项时,以后者为准,否则以匹配项为准 </Directory>
7.定义默认主页
DirectoryIndex index.html index.html.var #默认主页为index.html,会依次向后查询
8.用户目录
<IfModule mod_userdir.c> UserDir disabled #禁止用户使用个人主页 #UserDir public_html #用户主页的目录,是用户家目录下的目录 </IfModule>
9.配置日志功能
LogLevel warn LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined #combined日志模版 LogFormat "%h %l %u %t \"%r\" %>s %b" common #common日志模版 LogFormat "%{Referer}i -> %U" referer #rederer日志模版 LogFormat "%{User-agent}i" agent #agent日志模版 CustomLog logs/access_log combined #这里使用的是combined的模版 %h: 客户端地址 %l: 远程登录名,通常为- %u: 认证时的远程用户名,没有认证时为- %t: 收到请求时的时间; %r: 请求报文的起始行; %>s: 响应状态码; %b: 响应报文的长度,单位为字节 %{Header_Name}i: 记录指定请求报文首部的内容
10.路径别名
Alias /icons/ "/var/www/icons/" #意味着访问http://Server_IP/icons/时,其页面文件来自于/var/www/icons/这个位置
11.设定默认字符集
AddDefaultCharset UTF-8 # 说明是使用UTF-8的字符集
原文:http://lidefu.blog.51cto.com/3429777/1380660