Linux CentOS7 httpd 配置注釋


本文首發:https://www.somata.net/2019/linux_centos_httpd_config_comment.html

如果沒看懂可以去看看官方發布的文檔 apache官方文檔

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 index.html			# 指定默認首頁
</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 /.noindex.html			# 錯誤返回代碼和網頁
</LocationMatch>
<Directory /usr/share/httpd/noindex>
    AllowOverride None
    Require all granted
</Directory>
Alias /.noindex.html /usr/share/httpd/noindex/index.html
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】獲取授權信息。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM