[root@apache httpd]# cat conf/httpd.conf
# 这是Apache服务的主要配置文件,包含httpd服务的各种指令.
# 指令字典:http://httpd.apache.org/docs/2.4/mod/directives.html
#httpd服务安装的目录位置
ServerRoot "/etc/httpd"
#ServerRoot可以使用的--prefix参数来 修改的默认位置configure
#并且服务器的大多数第三方发行版的默认位置都不同于上面列出的默认位置。
#
#httpd服务监听的ip与端口
Listen 80
Listen 8080
#告诉服务器在指定的端口或地址和端口组合上接受传入的请求
#如果仅指定端口号,则服务器将在所有接口上侦听给定的端口。
#如果提供了IP地址和端口,则服务器将侦听给定的端口和接口。
#可以同时使用多个Listen来指定监听的端口和接口。
#Listen是必须配置的指令,不配置的话,服务将无法启动。
#加载除主配文件外的其它配置文件
Include conf.modules.d/*.conf
#指定服务运行的用户ID (可以通过ID或者名称来指定)
User apache
#指定服务运行的群组ID
Group apache
#使用上述功能,服务必须首先由root用户运行一个父进程。
#如果以非root用户身份启动httpd服务,那将无法更改为其它权限较低的用户
#如果是以root用户身份启动的httpd服务,那么,除了父进程是root用户启动
#其它进程与线程均为指定的用户启动
#设置服务管理员的电子邮件地址
ServerAdmin root@localhost
#httpd服务自身的标识
ServerName www.mpmlearning.com
#如果未指定ServerName,服务器首先尝试向操作系统询问系统主机名
#以推断出客户端可见的主机名,如果失败,则对系统上存在的IP地址执行反向查找。
#
#封装了一组只针对目标目录的指令配置
<Directory />
#AllowOverride设置为None,.htaccess文件将被完全忽略。
AllowOverride none
#对/目录文件访问被无条件拒绝。
Require all denied
</Directory>
#配置web文件的path
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory "/var/www/html">
#indexes
#如果请求映射到目录的URL并没有DirectoryIndex
#(如,index.html)在该目录中,将会执行mod_autoindex。
#FollowSymLinks
#服务将会严格遵守Directory匹配的路径
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
#当客户端通过在目录名称末尾指定/来请求目录索引时,该伪指令设置要查找的资源列表
DirectoryIndex index.html
</IfModule>
#封装限制指定文件的访问权限与一些其它的设置
<Files ".ht*">
Require all denied
</Files>
#配置服务错误信息输出的path
ErrorLog "logs/error_log"
#配置日志的等级,即ErrorLog的详细程度。
LogLevel warn
#其它日志级别在下文LogLevel中详细说明
<IfModule log_config_module>
#指定访问日志文件的格式
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#CustomLog "logs/access_log" common
#用于将请求记录到服务器 combined为LogFormat指令定义的格式昵称
CustomLog "logs/access_log" combined
#配置方法二: CustomLog "logs/access_log" "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
</IfModule>
<IfModule alias_module>
# Alias /webpath /full/filesystem/path
#映射需要mod——cgi处理的cgi脚本的绝对路径
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
#指定媒体类型的配置文件path
TypesConfig /etc/mime.types
#添加新增的类型,而不需要修改mime.types文件
#AddType application/x-gzip .tgz
#将给定的文件扩展名映射到指定的HTTP内容编码。
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#将文件扩展名映射到指定的处理程序
#AddHandler cgi-script .cgi
#AddHandler type-map var
AddType text/html .shtml
#将文件扩展名映射到将处理服务器响应的过滤器
AddOutputFilter INCLUDES .shtml
</IfModule>
#指定要添加到响应的媒体类型charset参数的默认值(字符编码的名称
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
#使用指定的magic文件根据文件内容启用MIME类型确定
MIMEMagicFile conf/magic
</IfModule>
#在传送过程中使用内存映射来读取文件
#EnableMMAP off
#使用内核sendfile支持将文件传递到客户端
EnableSendfile on
#加载服务器配置文件中的其他配置文件
IncludeOptional conf.d/*.conf
LogLevel
Level | Description | Example |
---|---|---|
emerg |
Emergencies - system is unusable. 无法使用 |
“Child cannot open lock file. Exiting” |
alert |
Action must be taken immediately. 必须做相应措施 |
“getpwuid: couldn’t determine user name from uid” |
crit |
Critical Conditions. 关键条件 |
“socket: Failed to get a socket, exiting child” |
error |
Error conditions. 错误条件 |
“Premature end of script headers” |
warn |
Warning conditions. 警告条件 |
“child process 1234 did not exit, sending another SIGHUP” |
notice |
Normal but significant condition. 正常信息 |
“httpd: caught SIGBUS, attempting to dump core in …” |
info |
Informational. 信息 |
“Server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers)…” |
debug |
Debug-level messages 调试级别信息 |
“Opening config file …” |
trace1 |
Trace messages | “proxy: FTP: control connection complete” |
trace2 |
Trace messages | “proxy: CONNECT: sending the CONNECT request to the remote proxy” |
trace3 |
Trace messages | “openssl: Handshake: start” |
trace4 |
Trace messages | “read from buffered SSL brigade, mode 0, 17 bytes” |
trace5 |
Trace messages | “map lookup FAILED: map=rewritemap key=keyname” |
trace6 |
Trace messages | “cache lookup FAILED, forcing new map lookup” |
trace7 |
Trace messages, dumping large amounts of data | “| 0000: 02 23 44 30 13 40 ac 34 df 3d bf 9a 19 49 39 15 |” |
trace8 |
Trace messages, dumping large amounts of data | “| 0000: 02 23 44 30 13 40 ac 34 df 3d bf 9a 19 49 39 15 |” |