1. [root@apache httpd]# cat conf/httpd.conf
  2. # 这是Apache服务的主要配置文件,包含httpd服务的各种指令.
  3. # 指令字典:http://httpd.apache.org/docs/2.4/mod/directives.html
  4. #httpd服务安装的目录位置
  5. ServerRoot "/etc/httpd"
  6. #ServerRoot可以使用的--prefix参数来 修改的默认位置configure
  7. #并且服务器的大多数第三方发行版的默认位置都不同于上面列出的默认位置。
  8. #
  9. #httpd服务监听的ip与端口
  10. Listen 80
  11. Listen 8080
  12. #告诉服务器在指定的端口或地址和端口组合上接受传入的请求
  13. #如果仅指定端口号,则服务器将在所有接口上侦听给定的端口。
  14. #如果提供了IP地址和端口,则服务器将侦听给定的端口和接口。
  15. #可以同时使用多个Listen来指定监听的端口和接口。
  16. #Listen是必须配置的指令,不配置的话,服务将无法启动。
  17. #加载除主配文件外的其它配置文件
  18. Include conf.modules.d/*.conf
  19. #指定服务运行的用户ID (可以通过ID或者名称来指定)
  20. User apache
  21. #指定服务运行的群组ID
  22. Group apache
  23. #使用上述功能,服务必须首先由root用户运行一个父进程。
  24. #如果以非root用户身份启动httpd服务,那将无法更改为其它权限较低的用户
  25. #如果是以root用户身份启动的httpd服务,那么,除了父进程是root用户启动
  26. #其它进程与线程均为指定的用户启动
  27. #设置服务管理员的电子邮件地址
  28. ServerAdmin root@localhost
  29. #httpd服务自身的标识
  30. ServerName www.mpmlearning.com
  31. #如果未指定ServerName,服务器首先尝试向操作系统询问系统主机名
  32. #以推断出客户端可见的主机名,如果失败,则对系统上存在的IP地址执行反向查找。
  33. #
  34. #封装了一组只针对目标目录的指令配置
  35. <Directory />
  36. #AllowOverride设置为None,.htaccess文件将被完全忽略。
  37. AllowOverride none
  38. #对/目录文件访问被无条件拒绝。
  39. Require all denied
  40. </Directory>
  41. #配置web文件的path
  42. DocumentRoot "/var/www/html"
  43. <Directory "/var/www">
  44. AllowOverride None
  45. # Allow open access:
  46. Require all granted
  47. </Directory>
  48. <Directory "/var/www/html">
  49. #indexes
  50. #如果请求映射到目录的URL并没有DirectoryIndex
  51. #(如,index.html)在该目录中,将会执行mod_autoindex。
  52. #FollowSymLinks
  53. #服务将会严格遵守Directory匹配的路径
  54. Options Indexes FollowSymLinks
  55. AllowOverride None
  56. Require all granted
  57. </Directory>
  58. <IfModule dir_module>
  59. #当客户端通过在目录名称末尾指定/来请求目录索引时,该伪指令设置要查找的资源列表
  60. DirectoryIndex index.html
  61. </IfModule>
  62. #封装限制指定文件的访问权限与一些其它的设置
  63. <Files ".ht*">
  64. Require all denied
  65. </Files>
  66. #配置服务错误信息输出的path
  67. ErrorLog "logs/error_log"
  68. #配置日志的等级,即ErrorLog的详细程度。
  69. LogLevel warn
  70. #其它日志级别在下文LogLevel中详细说明
  71. <IfModule log_config_module>
  72. #指定访问日志文件的格式
  73. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  74. LogFormat "%h %l %u %t \"%r\" %>s %b" common
  75. <IfModule logio_module>
  76. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  77. </IfModule>
  78. #CustomLog "logs/access_log" common
  79. #用于将请求记录到服务器 combined为LogFormat指令定义的格式昵称
  80. CustomLog "logs/access_log" combined
  81. #配置方法二: CustomLog "logs/access_log" "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
  82. </IfModule>
  83. <IfModule alias_module>
  84. # Alias /webpath /full/filesystem/path
  85. #映射需要mod——cgi处理的cgi脚本的绝对路径
  86. ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
  87. </IfModule>
  88. <Directory "/var/www/cgi-bin">
  89. AllowOverride None
  90. Options None
  91. Require all granted
  92. </Directory>
  93. <IfModule mime_module>
  94. #指定媒体类型的配置文件path
  95. TypesConfig /etc/mime.types
  96. #添加新增的类型,而不需要修改mime.types文件
  97. #AddType application/x-gzip .tgz
  98. #将给定的文件扩展名映射到指定的HTTP内容编码。
  99. #AddEncoding x-compress .Z
  100. #AddEncoding x-gzip .gz .tgz
  101. AddType application/x-compress .Z
  102. AddType application/x-gzip .gz .tgz
  103. #将文件扩展名映射到指定的处理程序
  104. #AddHandler cgi-script .cgi
  105. #AddHandler type-map var
  106. AddType text/html .shtml
  107. #将文件扩展名映射到将处理服务器响应的过滤器
  108. AddOutputFilter INCLUDES .shtml
  109. </IfModule>
  110. #指定要添加到响应的媒体类型charset参数的默认值(字符编码的名称
  111. AddDefaultCharset UTF-8
  112. <IfModule mime_magic_module>
  113. #使用指定的magic文件根据文件内容启用MIME类型确定
  114. MIMEMagicFile conf/magic
  115. </IfModule>
  116. #在传送过程中使用内存映射来读取文件
  117. #EnableMMAP off
  118. #使用内核sendfile支持将文件传递到客户端
  119. EnableSendfile on
  120. #加载服务器配置文件中的其他配置文件
  121. 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 |”