Apache的配置文件http.conf参数含义详解(3)
来源: www.ixdba.net 
作者: IXDBA.NET官方
时间:2008-03-29 阅读:37
本文章共7426字,分5页,当前第3页,快速翻页:1 2 3 4 5
使其它用户能够读取该文件。
UserDir /var/html (the URL http://www.clusting.com/~bearzhang/file.html 将读取 /var/html/bearzhang/file.html)
UserDir /var/www/*/docs (the URL http://www.clusting.com/~bearzhang/file.html 将读取 /var/www/bearzhang/docs/file.html)
日志 的设置
(1) 错误日志的设置
ErrorLog logs/error_log # 日志的保存位置 www.ixdba.net
LogLevel warn # 日志的级别
显示的格式日下:
[Mon Oct 10 15:54:29 2005] [error] [client 192.168.10.22] access to /download/ failed, reason: user admin not allowed access
(2) 访问日志设置
日志的缺省格式有如下几种:
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %b" common #common 为日志格式名称
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access_log common
格式中的各个参数如下:
%h -- 客户端的 ip 地址或主机名
%l --The 这是由客户端 identd 判断的 RFC 1413 身份,输出中的符号 "-" 表示此处信息无效。
%u -- 由 HTTP 认证系统得到的访问该网页的客户名。有认证时才有效,输出中的符号 "-" 表示此处信息无效。
%t -- 服务器完成对请求的处理时的时间。
"%r" -- 引号中是客户发出的包含了许多有用信息的请求内容。
%>s -- 这个是服务器返回给客户端的状态码。
%b -- 最后这项是返回给客户端的不包括响应头的字节数。
"%{Referer}i" -- 此项指明了该请求是从被哪个网页提交过来的。
"%{User-Agent}i" -- 此项是客户浏览器提供的浏览器识别信息。
下面是一段访问日志的实例:
192.168.10.22 - bearzhang [10/Oct/2005:16:53:06 +0800] "GET /download/ HTTP/1.1" 200 1228
192.168.10.22 - - [10/Oct/2005:16:53:06 +0800] "GET /icons/blank.gif HTTP/1.1" 304 -
192.168.10.22 - - [10/Oct/2005:16:53:06 +0800] "GET /icons/back.gif HTTP/1.1" 304 -
各参数的详细解释,请参阅: http://www.clusting.com/Apache/ApacheManual/logs.html
用户认证的配置
(1)in the httpd.conf:
AccessFileName .htaccess
.........
Alias /download/ "/var/www/download/"
<Directory "/var/www/download">
Options Indexes
AllowOverride AuthConfig
</Directory>
(2) create a password file:
/usr/local/apache2/bin/htpasswd -c /var/httpuser/passwords bearzhang
(3)onfigure the server to request a password and tell the server which users are allowed access.
vi /var/www/download/.htaccess:
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/httpuser/passwords
Require user bearzhang
#Require valid-user #all valid user
虚拟主机的配置
(1) 基于 IP 地址的虚拟主机配置
Listen 80
<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example2.org
</VirtualHost>
(2) 基于 IP 和多端口的虚拟主机配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>
阅读更多内容 :<<上一页 · 1 · 2 · 3 · 4 · 5 · 下一页>>