当前位置: 移动技术网 > 科技>操作系统>Linux > Linux CentOS7 httpd 服务配置注释

Linux CentOS7 httpd 服务配置注释

2019年09月04日  | 移动技术网科技  | 我要评论

apache 配置注释

本文首发:https://www.cnblogs.com/somata/p/linuxcentoshttpdconfigcomment.html

如果没看懂可以去看看官方发布的文档

conf/httpd.conf

serverroot "/etc/httpd"                 # 指定服务配置根目录
listen 80                               # 监听端口
include conf.modules.d/*.conf           # 包含模块配置文件
user apache                             # 使用的用户进程和组
group apache
serveradmin root@localhost              # 服务器管理员邮箱,用于错误提示。
documentroot "/var/www/html"            # 指定服务网页根目录
<directory />                           # 为指定目录设置不同权限
    allowoverride none                  # 禁止使用.htaccess 中的指令
    require all denied                  # 禁止所有访问
</directory>
<directory "/var/www">
    allowoverride none
    require all granted                 # 允许访问
</directory>
<directory "/var/www/html">
    options indexes followsymlinks      # 允许的参数(索引(建议禁用),跟随软连接)
    allowoverride none
    require all granted
</directory>
<ifmodule dir_module>
    directoryindex            # 指定默认首页
</ifmodule>
<files ".ht*">
    require all denied                  # 禁止访问该文件
</files>
errorlog "logs/error_log"               # 日志记录
loglevel warn
<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" combined    # 指定日志文件名和格式(结合)
</ifmodule>
<ifmodule alias_module>
    scriptalias /cgi-bin/ "/var/www/cgi-bin/"   # 路径别名
</ifmodule>
<directory "/var/www/cgi-bin">
    allowoverride none
    options none
    require all granted
</directory>
<ifmodule mime_module>                      # 指定文件格式和mime对应
    typesconfig /etc/mime.types
    addtype application/x-compress .z
    addtype application/x-gzip .gz .tgz
    addtype text/html .shtml
    addoutputfilter includes .shtml
</ifmodule>
adddefaultcharset utf-8                     # 指定默认编码
<ifmodule mime_magic_module>
    mimemagicfile conf/magic                # 指定mime
</ifmodule>
enablesendfile on                           # 开启sendfile功能
# sendfile功能必须在linux kernel 2.1版本以后内核中才能开启
# sendfile功能直接跳过了将内容复制到用户缓冲区的过程,直接将文件内容复制到了socket缓冲区
# 加快了文件的发送速度。
includeoptional conf.d/*.conf

conf.d/autoindex.conf

indexoptions fancyindexing htmltable versionsort        # 索引选项
alias /icons/ "/usr/share/httpd/icons/"
<directory "/usr/share/httpd/icons">
    options indexes multiviews followsymlinks
    allowoverride none
    require all granted
</directory>
addiconbyencoding (cmp,/icons/compressed.gif) x-compress x-gzip # 根据文件编码来分配图标
addiconbytype (txt,/icons/text.gif) text/*                      # 根据文件类型来分配图标
addiconbytype (img,/icons/image2.gif) image/*
addiconbytype (snd,/icons/sound2.gif) audio/*
addiconbytype (vid,/icons/movie.gif) video/*
addicon /icons/binary.gif .bin .exe                             # 根据文件后缀来分配图标
addicon /icons/binhex.gif .hqx
addicon /icons/tar.gif .tar
addicon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
addicon /icons/compressed.gif .z .z .tgz .gz .zip
addicon /icons/a.gif .ps .ai .eps
addicon /icons/layout.gif .html .shtml .htm .pdf
addicon /icons/text.gif .txt
addicon /icons/c.gif .c
addicon /icons/p.gif .pl .py
addicon /icons/f.gif .for
addicon /icons/dvi.gif .dvi
addicon /icons/uuencoded.gif .uu
addicon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
addicon /icons/tex.gif .tex
addicon /icons/bomb.gif /core
addicon /icons/bomb.gif */core.*
addicon /icons/back.gif ..
addicon /icons/hand.right.gif readme
addicon /icons/folder.gif ^^directory^^
addicon /icons/blank.gif ^^blankicon^^
defaulticon /icons/unknown.gif                  # 默认的未知文件
readmename readme.html                          # 和下面一个共同用于添加索引的上下文件内容
headername header.html
indexignore .??* *~ *# header* readme* rcs cvs *,v *,t  # 指定要隐藏的文件。

conf.d/welcome.conf

<locationmatch "^/+$">                                      # 仅将该规则用于规则匹配的url
    options -indexes                                            # 去除所有参数
    errordocument 403 /.no            # 错误返回代码和网页
</locationmatch>
<directory /usr/share/httpd/noindex>
    allowoverride none
    require all granted
</directory>
alias /.no /usr/share/httpd/noindex/
alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png

conf.d/ssl.conf

listen 443 https
sslpassphrasedialog exec:/usr/libexec/httpd-ssl-pass-dialog     # 加密私钥的对话类型
sslsessioncache         shmcb:/run/httpd/sslcache(512000)       # ssl对话密钥的存储位置
sslsessioncachetimeout  300                                     # ssl对话密钥的超时时间
sslrandomseed startup file:/dev/urandom  256                    # 随机种子的获取地址
sslrandomseed connect builtin                                   # 如果无法使用urandom则使用内置随机数生成器
sslcryptodevice builtin                                         # 硬件加密策略,默认使用内置,可是使用openssl engine 插叙是否可是使用其他硬件加密策略
#sslcryptodevice rdrand # 这个是intel的硬件加密引擎
<virtualhost _default_:443>
    errorlog logs/ssl_error_log                 # 指定错误日志位置
    transferlog logs/ssl_access_log             # 指定默认日志位置
    loglevel warn                               # 指定日志级别
    sslengine on                                # 开启 ssl 加密引擎
    sslprotocol all -sslv2                      # 配置所加密策略可用,取消使用sslv2
    sslciphersuite high:medium:!anull:!md5:!seed:!idea  # 密码交换策略
    # high:使用所有triple-des的密码
    # medium:所有具有128位加密的密码
    # 这里的 ! 是用于禁止指定的策略分别是anull(没有身份验证),md5(md5哈希函数),idea(idea加密)
    sslcertificatefile /etc/pki/tls/certs/localhost.crt # 证书存储位置
    sslcertificatekeyfile /etc/pki/tls/private/localhost.key    # 密钥存储位置
    <files ~ "\.(cgi|shtml|phtml|php3?)$">
        ssloptions +stdenvvars                  # 这里的选项是用于ssl连接的额外配置
        # 主要是给脚本提供一些其他的与ssl相关环境变量,不过会消耗部分系统资源,推荐关闭。下同。
    </files>
    <directory "/var/www/cgi-bin">
        ssloptions +stdenvvars
    </directory>
    browsermatch "msie [2-5]" \                 # 这个是关于user-agent的相关参数
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    # 第一个参数是正则匹配user-agent,然后会创建后面的环境这些环境变量,并且变量默认值为1
    customlog logs/ssl_request_log \            # 日志参数
              "%t %h %{ssl_protocol}x %{ssl_cipher}x \"%r\" %b"
</virtualhost>

本文经「原本」原创认证,作者乾坤盘,访问yuanben.io查询【kwdnerpu】获取授权信息。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网