日志设定
错误日志(使用相对路径,/etc/httpd)
[root@lab1 conf]# grep ^ErrorLog httpd.conf
ErrorLog "logs/error_log"
[root@lab1 conf]# grep ^LogLevel httpd.conf -B 3
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
访问日志
[root@lab1 conf]# grep CustomLog httpd.conf
# a CustomLog directive (see below).
#CustomLog "logs/access_log" common
CustomLog "logs/access_log" combined
[root@lab1 conf]# grep LogFormat httpd.conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
%h:客户端IP地址
%l:用户登录时的用户名,-表示为空
%u:用户认证时的用户名
%t:服务器收到请求时的时间
%r:请求报文的首行信息(方法 网址 版本)
%>s:响应状态码
$b:响应报文的大小,单位是字节,不包含响应报文首部
%[referer]i:请求报文当中"referer"首部的值,当前资源的访问入口,即来自于哪个页面的超链接请求跳转而来
%[User-Agent]i:请求报文当中"User-Agent"首部的值,即发出请求用到的应用程序
详情
[root@lab1 conf]# tail /var/log/httpd/access_log | tail -1
172.20.0.1 - - [03/May/2019:11:39:00 -0400] "GET /noindex/css/fonts/Light/OpenSans-Light.ttf HTTP/1.1" 404 240 "http://172.20.0.131:8080/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
路径别名
使用路径别名配置访问路径的实例:
[root@lab1 ~]# cd /www/htdocs
[root@lab1 htdocs]# mkdir bbs
[root@lab1 htdocs]# cd bbs
[root@lab1 bbs]# vim index.html
[root@lab1 bbs]# cat index.html
Page at /www/htdocs/bbs
[root@lab1 conf]# curl 172.20.0.131/bbs/
Page at /www/htdocs/bbs
[root@lab1 bbs]# pwd
/www/htdocs/bbs
[root@lab1 bbs]# cd ..
[root@lab1 htdocs]# mkdir /forum
[root@lab1 htdocs]# vim /forum/index.html
[root@lab1 htdocs]# cat /forum/index.html
Page at /forum
[root@lab1 conf]# vim httpd.conf
[root@lab1 conf]# grep ^Alias httpd.conf
Alias /bbs/ "/forum/"
[root@lab1 conf]# systemctl restart httpd
[root@lab1 conf]# curl 172.20.0.131/bbs/
Page at /forum
设定默认字符集
AddDefaultCharset
基于用户的访问控制
认证质询