Server - Apache - Introduction to the basic ideas configuration file

  1. Outline
    1. Quick description apache configuration file some ideas
  2. background
    1. Beginner apache
    2. School for several days, will be a little something
      1. Will install, start and stop
      2. Put the directory it out
      3. On the deployment of a static page
      4. Simply configure the most basic access_log
      5. Profiles can not read completely
      6. If the work, it is estimated one day be able to write the configuration
        1. Who knows ah ...
    3. So first take a brief look at some of the basic ideas of the main configuration file, right
      1. Specific configuration items may also put much
  3. surroundings
    1. VM - OS
      1. VirtualBox6.0
      2. CentOS7.2
    2. apache
      1. 2.4.6-90
      2. yum install
    3. Host - OS
      1. Win10
    4. The internet
      1. Virtual machine using bridged mode

1. Profiles

  1. Outline
    1. apache main configuration file
  2. path

    # 默认
    /etc/httpd/conf/http.conf

2. Ideas

  1. Outline
    1. apache configuration file ideas
  2. Thinking
    1. Modular
      1. All functions apache, in fact, are to be implemented in each module
        1. Design ideas
          1. Differentiated responsibilities
          2. Allow for better flexibility
    2. core module
      1. The most basic module
      2. All modules will be with the apache
      3. base module
        1. The default apache not only a module
        2. status for the base module, are built in the apache
          1. This status, can be explained in the official website of the module, see
          2. If you are not the official website, is not so sure the base
          3. A base module
    3. Classification Module
      1. MPM - multi-threaded processing module
        1. effect
          1. Processing, forwarding the request
        2. Very important
          1. And only one
      2. Base - The base module
        1. default
          1. apache comes
          2. Of course, you can also remove
      3. Extension - expansion module
        1. expand
          1. Without default
          2. You can think of ways to introduce
            1. When introduced into the official website, said the need to recompile or at compile time
              1. Do not understand C, do not know will not be very troublesome
      4. Experimental - Experimental Module
        1. experiment
          1. Without default
          2. You want to introduce yourself with too
          3. Of course, since it is experimental, there will certainly be a variety of pit
      5. External - external module
        1. Outside
          1. Third-party developers
          2. I'm sorry, the official website can not provide support ....
    4. other
      1. file
      2. path

3. Profiles

  1. Outline
    1. A brief description of the default configuration file some ideas
  2. simplify
    1. the reason
      1. The original configuration files, comments, blank lines too
      2. Use tools to simplify what is actually drawn into effect
    2. table of Contents

      # 过滤掉 注释 和 空行
      > cat httpd.conf | grep -vE '#|^$'
    3. result
      1. We came to the conclusion about a 60-line configuration file
        1. I change the log-related, it is not possible to accurately estimate the number of rows in the default configuration file
        2. Insist estimated it would probably be okay 57

4. CI

  1. classification
    1. Roughly divided into four categories

1. Direct configuration

  1. example

    # 根路径为 /etc/httpd
    ServerRoot "/etc/httpd" 
    # 监听 80 端口
    Listen 80 
    # 操作用户名 apache
    User apache 
    # 操作用户组 apache
    Group apache 
  2. Thinking
    1. core module
      1. These are the core module supports property
        1. At least for now, it is like this, if you later encounter, will be back adjustment
        2. I scholarship this stuff a day or two, please forgive me ...
    2. Configuration
      1. Basically kv type of configuration
        1. key
          1. Configuration Item
        2. value
          1. The contents of the configuration
          2. But it seems the path was in double quotes
      2. Behind other places, there have been class configuration kvv
        1. I still have not met, met talk about it later

2. <IfModule >

  1. Outline
    1. Module configuration defining
  2. example

    # 配置 log_config_module 
    <IfModule log_config_module>
        # 配置日志格式, 并给出别名 combined
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
        LogFormat "%h %l %u %t \"%r\" %>s %b" common
        LogFormat  "%t  %h  %A  %p  \"%r\" %D   %X  %I  %O %>s"  demo
        # 如果 logio_module 模块存在, 则会生效
        <IfModule logio_module>
          LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
        </IfModule>
        # 配置默认 access_log 格式
        CustomLog "logs/access_log" demo
    </IfModule>
  3. Thinking
    1. IfModule
      1. If the module is present, the following configuration takes effect
    2. CustomLog "logs/access_log" demo
      1. kvv mode
        1. Formulate log format
        2. Log file for the demo alias corresponding format

3. <Directory >

  1. Outline
    1. Do directory restrictions
    2. To be honest, I was not too clear
  2. example

    # 限定 根目录
    <Directory />
        # 拒绝修改
        AllowOverride None
        # 拒绝所有访问
        Require all denied
    </Directory>
  3. directory
    1. Scoped
      1. Command in the label limited, only in a defined directory, subdirectory into force
        1. Such as the above, is the root of the entry into force
    2. Issues covered
      1. / Default access is to allow all
        1. This is clearly unscientific
      2. / Var / www / html permission, later changed all granted
        1. In the case of all denied, opening up access to specific directories

4. <Files >

  1. Outline
    1. Restrictions similar directory
    2. The restrictions for a specific file
  2. example

    # 限制所有 .ht 文件
    <Files ".ht*">
        # 拒绝所有访问
        Require all denied
    </Files>

5. Other

  1. Configuration
    1. apache server module is based on
      1. So in essence, the configuration of the object, in fact, is a server, rather than the module itself
      2. So, many modules, it also brings a number of configuration
      3. Short-lived fad, is endless talk ...
  2. purpose
    1. This article first have a profile
      1. Configuration would be able to know what it means
      2. Even after a problem, but also know how to find the document
        1. Go first module, find the document
        2. English official document, in fact, easy to understand

ps

  1. ref
    1. grep command filter configuration file comments and blank lines
    2. Module status
    3. Require
  2. Follow-up
    1. Try to do something to add modules operating
    2. apache cookbook this book really is not very friendly for the novice ...

Guess you like

Origin www.cnblogs.com/xy14/p/12449108.html