# ServerRoot:服务器的基础目录,一般来说它将包含conf/和logs/子目录,其它配置文件的相对路径即基于此目录。默认为安装目录,不需更改。
# 语法:ServerRoot /path/to/directory
# 例如:ServerRoot "/usr/local/apache"
#
ServerRoot "/etc/httpd"
# Listen:定义apache监听的端口
# 语法:Listen [IpAddress:]port
# 例如:Listen 80
#Listen 12.34.56.78:80
Listen 80
# LoadModule:加载特定的DSO模块。Apache默认将已编译的DSO模块存放于/usr/local/apache/modules目录结中。如果想使用使用某一个DSO模块,需用LoadModule指令进行加载;
# 语法:LoadModule some_module /path/to/module
# 例如:LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
# LoadModule foo_module modules/mod_foo.so
#
#加载特定的DSO模块的配置文件
Include conf.modules.d/*.conf
#设置实际提供服务的子进程的用户。
#设置提供服务的Apache子进程运行时的用户组。
User apache
Group apache
#ServerAdmin:设置管理员邮件地址,当apache服务器发生错误的时候,邮件地址就会出现在错误页面上。
# 语法:ServerAdmin email_address
# 例如:ServerAdmin [email protected]
ServerAdmin root@localhost
#ServerName:设置服务器用于辨识自己的主机名和端口号。
# 语法:ServerName 主机名[:port]
# 例如:ServerName www.example.com
#ServerName www.example.com:80
#
#限制httpd.conf访问操作系统的root目录
#
AllowOverride none
Require all denied
# 设置网站根目录,服务器会将请求中的URL附加到DocumentRoot后面以构成指向文档的路径。
DocumentRoot "/var/www/html"
#
# 定义 /var/www.路径访问属性
#
AllowOverride None
# Allow open access:
Require all granted
# 定义WEB root目录的访问属性。
#
# Indexes:缺少指定的默认页面时,允许将目录中的所有文件以列表形式返回给用户;
# FollowSymLinks:是否将符号连接所指向的文件打开;
# None:所有选项都不启用
# All:所有选项都启用
# ExecCGI:允许使用mod_cgi模块执行CGI脚本
# MultiViews:允许使用mod_negotiation(协商),实现内容协商
# Includes:允许使用mod_include模块实现SSI(服务器端包含)
# SymLinksifOwnerMatch:在链接文件属主数组与原始文件的属主属组相同时,允许跟随符
#
Options Indexes FollowSymLinks
#
# AllowOverride参数就是指明Apache服务器是否去找.htacess文件作为配置文件,
# 如果设置为none,那么服务器将忽略.htacess文件,如果设置为All,那么所有在.htaccess文件里有的指令都将被重写
#
AllowOverride None
#
# Require 访问控制指令,
# 允许所有访问请求 Require all granted
# 拒绝所有访问请求 Require all denied
# 只允许来自特定域名主机的访问请求,其他请求将被拒绝 Require host google.com
# 只允许来自特定IP或IP段的访问请求,其他请求将被拒绝 Require ip 192.120 192.168.100 192.168.1.1
Require all granted
#
# 设置默认目录资源列表文件,默认index.html
#
DirectoryIndex index.html
#
# 拒绝对.ht开头文件的访问,以保护.htaccess文件
#
Require all denied
#
# ErrorLog指令指定了当服务器遇到错误时记录错误日志的文件。如果file-path不是一个以斜杠(/)开头的绝对路径,那么将被认为是一个相对于ServerRoot的相对路径。
#
ErrorLog "logs/error_log"
#
# 其中LogLevel用于调整记于错误日志中的信息的详细程度。
#
LogLevel warn
#
# 定义访问日志的格式
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a
# container, they will be logged here. Contrariwise, if you *do*
# define per-
# logged therein and *not* in this file.
#
#CustomLog "logs/access_log" common
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
CustomLog "logs/access_log" combined
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.example.com/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a
# the filesystem path.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
AllowOverride None
Options None
Require all granted
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig /etc/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi
# For type maps (negotiated resources):
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
#
# 设置apache默认使用的字符集。GB2312,UTF-8等,off为关闭
#
AddDefaultCharset UTF-8
#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type. The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
MIMEMagicFile conf/magic
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#
#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on
# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
#
#Apache服务器虚拟主机(vhost)常用配置
#
DocumentRoot "/var/www/html"
ServerName www.centos.com
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ErrorLog "logs/port_80-error.log"
CustomLog "logs/port_80-access.log" common
#
DocumentRoot "/var/www/html"
ServerName www.centos.com
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ErrorLog "logs/port_80-error.log"
CustomLog "logs/port_80-access.log" common