- Outline
- Quick description apache configuration file some ideas
- background
- Beginner apache
- School for several days, will be a little something
- Will install, start and stop
- Put the directory it out
- On the deployment of a static page
- Simply configure the most basic access_log
- Profiles can not read completely
- If the work, it is estimated one day be able to write the configuration
- Who knows ah ...
- So first take a brief look at some of the basic ideas of the main configuration file, right
- Specific configuration items may also put much
- surroundings
- VM - OS
- VirtualBox6.0
- CentOS7.2
- apache
- 2.4.6-90
- yum install
- Host - OS
- Win10
- The internet
- Virtual machine using bridged mode
- VM - OS
1. Profiles
- Outline
- apache main configuration file
path
# 默认 /etc/httpd/conf/http.conf
2. Ideas
- Outline
- apache configuration file ideas
- Thinking
- Modular
- All functions apache, in fact, are to be implemented in each module
- Design ideas
- Differentiated responsibilities
- Allow for better flexibility
- Design ideas
- All functions apache, in fact, are to be implemented in each module
- core module
- The most basic module
- All modules will be with the apache
- base module
- The default apache not only a module
- status for the base module, are built in the apache
- This status, can be explained in the official website of the module, see
- If you are not the official website, is not so sure the base
- A base module
- Classification Module
- MPM - multi-threaded processing module
- effect
- Processing, forwarding the request
- Very important
- And only one
- effect
- Base - The base module
- default
- apache comes
- Of course, you can also remove
- default
- Extension - expansion module
- expand
- Without default
- You can think of ways to introduce
- When introduced into the official website, said the need to recompile or at compile time
- Do not understand C, do not know will not be very troublesome
- When introduced into the official website, said the need to recompile or at compile time
- expand
- Experimental - Experimental Module
- experiment
- Without default
- You want to introduce yourself with too
- Of course, since it is experimental, there will certainly be a variety of pit
- experiment
- External - external module
- Outside
- Third-party developers
- I'm sorry, the official website can not provide support ....
- Outside
- MPM - multi-threaded processing module
- other
- file
- path
- Modular
3. Profiles
- Outline
- A brief description of the default configuration file some ideas
- simplify
- the reason
- The original configuration files, comments, blank lines too
- Use tools to simplify what is actually drawn into effect
table of Contents
# 过滤掉 注释 和 空行 > cat httpd.conf | grep -vE '#|^$'
- result
- We came to the conclusion about a 60-line configuration file
- I change the log-related, it is not possible to accurately estimate the number of rows in the default configuration file
- Insist estimated it would probably be okay 57
- We came to the conclusion about a 60-line configuration file
- the reason
4. CI
- classification
- Roughly divided into four categories
1. Direct configuration
example
# 根路径为 /etc/httpd ServerRoot "/etc/httpd" # 监听 80 端口 Listen 80 # 操作用户名 apache User apache # 操作用户组 apache Group apache
- Thinking
- core module
- These are the core module supports property
- At least for now, it is like this, if you later encounter, will be back adjustment
- I scholarship this stuff a day or two, please forgive me ...
- These are the core module supports property
- Configuration
- Basically kv type of configuration
- key
- Configuration Item
- value
- The contents of the configuration
- But it seems the path was in double quotes
- key
- Behind other places, there have been class configuration kvv
- I still have not met, met talk about it later
- Basically kv type of configuration
- core module
2. <IfModule
>
- Outline
- Module configuration defining
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>
- Thinking
- IfModule
- If the module is present, the following configuration takes effect
- CustomLog "logs/access_log" demo
- kvv mode
- Formulate log format
- Log file for the demo alias corresponding format
- kvv mode
- IfModule
3. <Directory
>
- Outline
- Do directory restrictions
- To be honest, I was not too clear
example
# 限定 根目录 <Directory /> # 拒绝修改 AllowOverride None # 拒绝所有访问 Require all denied </Directory>
- directory
- Scoped
- Command in the label limited, only in a defined directory, subdirectory into force
- Such as the above, is the root of the entry into force
- Command in the label limited, only in a defined directory, subdirectory into force
- Issues covered
- / Default access is to allow all
- This is clearly unscientific
- / Var / www / html permission, later changed all granted
- In the case of all denied, opening up access to specific directories
- / Default access is to allow all
- Scoped
4. <Files
>
- Outline
- Restrictions similar directory
- The restrictions for a specific file
example
# 限制所有 .ht 文件 <Files ".ht*"> # 拒绝所有访问 Require all denied </Files>
5. Other
- Configuration
- apache server module is based on
- So in essence, the configuration of the object, in fact, is a server, rather than the module itself
- So, many modules, it also brings a number of configuration
- Short-lived fad, is endless talk ...
- apache server module is based on
- purpose
- This article first have a profile
- Configuration would be able to know what it means
- Even after a problem, but also know how to find the document
- Go first module, find the document
- English official document, in fact, easy to understand
- This article first have a profile
ps
- ref
- Follow-up
- Try to do something to add modules operating
- apache cookbook this book really is not very friendly for the novice ...