#【全局配置】
#定义网站根目录,一下所有目录以此目录为相对路径
ServerRoot "/etc/httpd"
#定义网站名称
ServerName localhost
#配置监听的端口,可设置多个,用空格隔开
Listen 80
#包含独立模块配置文件
Include conf.modules.d/*.conf
#定义运行的用户组
User apache
Group apache
#定义服务器管理员
ServerAdmin root@localhost
#【核心配置】
#定义文档根目录权限
<Directory />
AllowOverride None
Require all denied
</Directory>
#定义www目录访问权限
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
#定义首页
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
#限制.ht*文件不可访问
<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>
#定义cgi-bin目录的访问权限
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
#定义mime模块属性
<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>
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
#定义默认字符
AddDefaultCharset UTF-8
#定义文件发送
EnableSendfile on
#引入配置文件
IncludeOptional conf.d/*.conf