Configuration file:
- /etc/httpd/conf/httpd.conf main configuration file
- /etc/httpd/conf.d/*.conf sub-configuration file
- /etc/httpd/conf.d/conf.modules.d/ The configuration file loaded by the module
Check the configuration syntax :httpd –t
Module file path:
- /etc/httpd/modules
- /usr/lib64/httpd/modules
Default web document root directory:
- / var / www / html
Log file directory:
- /var/log/httpd/access_log access log
- /var/log/httpd/error_log error log
Default profile
[root@centos8 ~]#grep -Ev '^ *#|^$' /etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd" ##设置根目录,后面的/实际都是在/etc/httpd/下面
Listen 80 ##监听端口,可重复出现,默认监听本机所有IP,可指定监听本机特定IP,例:192.168.1.100:8080
Include conf.modules.d/*.conf ##包含加载模块配置目录
User apache ##运行httpd的用户
Group apache ##运行httpd的组
ServerAdmin root@localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html" ##指向的路径为URL路径的起始位置
<Directory "/var/www"> ##/path 必须显式授权后才可以访问
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 ##定义站点主页面,可加如:index.htm index.php(需安装PHP模块)
##如访问www.yunmix.top和www.yunmix.top/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>
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
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf ##包含子配置文件