Redhat Enterprise Linux 5下apache部署及简单的配置过程(4)

第二部分,主服务器配置

#

# The directives in this section set up the values used by the 'main'

# server, which responds to any requests that aren't handled by a

# <VirtualHost> definition. These values also provide defaults for

# any <VirtualHost> containers you may define later in the file.

#

# All of these directives may appear inside <VirtualHost> containers,

# in which case these default settings will be overridden for the

# virtual host being defined.

#

#

# ServerAdmin: Your address, where problems with the server should be

# e-mailed. This address appears on some server-generated pages, such

# as error documents. e.g. admin@your-domain.com

#

ServerAdmin root@localhost

apache

服务器管理员邮箱的ip地址

#

# ServerName gives the name and port that the server uses to identify itself.

# This can often be determined automatically, but we recommend you specify

# it explicitly to prevent problems during startup.

#

# If this is not set to valid DNS name for your host, server-generated

# redirections will not work. See also the UseCanonicalName directive.

#

# If your host doesn't have a registered DNS name, enter its IP address here.

# You will have to access it by its address anyway, and this will make

# redirections work in a sensible way.

#

#ServerName [url]:80[/url]

#

# UseCanonicalName: Determines how Apache constructs self-referencing

# URLs and the SERVER_NAME and SERVER_PORT variables.

# When set "Off", Apache will use the Hostname and Port supplied

# by the client. When set "On", Apache will use the value of the

# ServerName directive.

#

UseCanonicalName Off

使用正式名称 关

#

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations.

#

DocumentRoot "/var/www/html"

根文档路径

#

# Each directory to which Apache has access can be configured with respect

# to which services and features are allowed and/or disabled in that

# directory (and its subdirectories).

#

# First, we configure the "default" to be a very restrictive set of

# features.

#

根访问权限

<Directory />

Options FollowSymLinks

AllowOverride None

</Directory>

#

# Note that from this point forward you must specifically allow

# particular features to be enabled - so if something's not working as

# you might expect, make sure that you have specifically enabled it

# below.

#

#

# This should be changed to whatever you set DocumentRoot to.

#

<Directory "/var/www/html">

可以改为你要设置的目录(慎重)

#

# Possible values for the Options directive are "None", "All",

# or any combination of:

# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

#

# Note that "MultiViews" must be named *explicitly* --- "Options All"

# doesn't give it to you.

#

# The Options directive is both complicated and important. Please see

# [url]#options[/url]

# for more information.

#

Options Indexes FollowSymLinks

选择指标的跟踪符号链接

#

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride None

允许覆盖无

#

# Controls who can get stuff from this server.

#

指定先执行允许访问规则在执行拒绝访问规则

Order allow,deny

Allow from all

允许所有连接

</Directory>

#

# UserDir: The name of the directory that is appended onto a user's home

# directory if a ~user request is received.

#

# The path to the end user account 'public_html' directory must be

# accessible to the webserver userid. This usually means that ~userid

# must have permissions of 711, ~userid/public_html must have permissions

# of 755, and documents contained therein must be world-readable.

# Otherwise, the client will only receive a "403 Forbidden" message.

#

# See also: [url]#forbidden[/url]

#

不允许每用户的服务器配置

<IfModule mod_userdir.c>

#

# UserDir is disabled by default since it can confirm the presence

# of a username on the system (depending on home directory

# permissions).

#

UserDir disable

#

# To enable requests to /~user/ to serve the user's public_html

# directory, remove the "UserDir disable" line above, and uncomment

# the following line instead:

#

#UserDir public_html

</IfModule>

#

# Control access to UserDir directories. The following is an example

# for a site where these directories are restricted to read-only.

#

#<Directory /home/*/public_html>

# AllowOverride FileInfo AuthConfig Limit

# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

# <Limit GET POST OPTIONS>

# Order allow,deny

# Allow from all

# </Limit>

# <LimitExcept GET POST OPTIONS>

# Order deny,allow

# Deny from all

# </LimitExcept>

#</Directory>

#

# DirectoryIndex: sets the file that Apache will serve if a directory

# is requested.

#

# The index.html.var file (a type-map) is used to deliver content-

# negotiated documents. The MultiViews Option can be used for the

# same purpose, but it is much slower.

#

DirectoryIndex index.html index.html.var

当访问服务器时,依次查找页面index.html、index.html.var

#

# AccessFileName: The name of the file to look for in each directory

# for additional configuration directives. See also the AllowOverride

# directive.

#

AccessFileName .htaccess

指定保护目录配置文件的名称

#

?lowing lines prevent .htaccess and .htpasswd files from being

# viewed by Web clients.

#

拒绝访问以.ht 开头的文件,即保证.htaccess 不被访问

<Files ~ "^\.ht">

Order allow,deny

Deny from all

</Files>

#

# TypesConfig describes where the mime.types file (or equivalent) is

# to be found.

#

TypesConfig /etc/mime.types

指定负责处理MIME 对应格式的配置文件的存放位置

#

# DefaultType is the default MIME type the server will use for a document

# if it cannot otherwise determine one, such as from filename extensions.

# If your server contains mostly text or HTML documents, "text/plain" is

# a good value. If most of your content is binary, such as applications

# or images, you may want to use "application/octet-stream" instead to

# keep browsers from trying to display binary files as though they are

# text.

#

指定默认的MIME 文件类型为纯文本或HTML 文件

DefaultType text/plain

#

# 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.

#

当mod_mime_magic.c 模块被加载时,指定magic信息码配置文件的存放位置

<IfModule mod_mime_magic.c>

# MIMEMagicFile /usr/share/magic.mime

MIMEMagicFile conf/magic

</IfModule>

#

# HostnameLookups: Log the names of clients or just their IP addresses

# e.g., [url][/url] (on) or 204.62.129.132 (off).

# The default is off because it'd be overall better for the net if people

# had to knowingly turn this feature on, since enabling it means that

# each client request will result in AT LEAST one lookup request to the

# nameserver.

#

HostnameLookups Off

只记录连接Apache 服务器的IP 地址,而不记录主机名

#

# EnableMMAP: Control whether memory-mapping is used to deliver

# files (assuming that the underlying OS supports it).

# The default is on; turn this off if you serve from NFS-mounted

# filesystems. On some systems, turning it off (regardless of

# filesystem) can improve performance; for details, please see

# [url]#enablemmap[/url]

#

#EnableMMAP off

#

# EnableSendfile: Control whether the sendfile kernel support is

# used to deliver files (assuming that the OS supports it).

# The default is on; turn this off if you serve from NFS-mounted

# filesystems. Please see

# [url]#enablesendfile[/url]

#

#EnableSendfile off

#

# ErrorLog: The location of the error log file.

# If you do not specify an ErrorLog directive within a <VirtualHost>

# container, error messages relating to that virtual host will be

# logged here. If you *do* define an error logfile for a <VirtualHost>

# container, that host's errors will be logged there and not here.

#

ErrorLog logs/error_log

错误日志存放位置

#

# LogLevel: Control the number of messages logged to the error_log.

# Possible values include: debug, info, notice, warn, error, crit,

# alert, emerg.

#

LogLevel warn

指定记录的错误信息的详细等级为warn 级别

#

# The following directives define some format nicknames for use with

# a CustomLog directive (see below).

#

几种记录日志的格式

LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common

LogFormat "%{Referer}i -&gt; %U" referer

LogFormat "%{User-agent}i" agent

# "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this

# requires the mod_logio module to be loaded.

#LogFormat "%h %l %u %t \"%r\" %&gt;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 <VirtualHost>

# container, they will be logged here. Contrariwise, if you *do*

# define per-<VirtualHost> access logfiles, transactions will be

# logged therein and *not* in this file.

#

#CustomLog logs/access_log common

#

# If you would like to have separate agent and referer logfiles, uncomment

# the following directives.

#

#CustomLog logs/referer_log referer

#CustomLog logs/agent_log agent

#

# For a single logfile with access, agent, and referer information

# (Combined Logfile Format), use the following directive:

#

CustomLog logs/access_log combined

指定访问日志记录格式 并指定存放位置

#

# Optionally add a line containing the server version and virtual host

# name to server-generated pages (internal error documents, FTP directory

# listings, mod_status and mod_info output etc., but not CGI generated

# documents or custom error documents).

# Set to "EMail" to also include a mailto: link to the ServerAdmin.

# Set to one of: On | Off | EMail

#

ServerSignature On

设置Apache 自己产生的页面中使用Apache 服务器版本的签名

# Aliases: Add here as many aliases as you need (with no limit). The format is

# Alias fakename realname

#

# Note that if you include a trailing / on fakename then the server will

# require it to be present in the URL. So "/icons" isn't aliased in this

# example, only "/icons/". If the fakename is slash-terminated, then the

# realname must also be slash terminated, and if the fakename omits the

# trailing slash, the realname must also omit it.

#

# We include the /icons/ alias for FancyIndexed directory listings. If you

# do not use FancyIndexing, you may comment this out.

#

内容协商目录访问别名

Alias /icons/ "/var/www/icons/"

apache手册访问别名

<Directory "/var/www/icons">

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

#

# WebDAV module configuration section.

WebDAV的模块配置

#

指定DAV 加锁数据库存放位置

<IfModule mod_dav_fs.c>

# Location of the WebDAV lock database.

DAVLockDB /var/lib/dav/lockdb

</IfModule>

#

# ScriptAlias: This controls which directories contain server scripts.

# ScriptAliases are essentially the same as Aliases, except that

# documents in the realname 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.

#

<Directory "/var/www/cgi-bin">

AllowOverride None

Options None

Order allow,deny

Allow from all

</Directory>

#

# Redirect allows you to tell clients about documents which used to exist in

# your server's namespace, but do not anymore. This allows you to tell the

# clients where to look for the relocated document.

# Example:

# Redirect permanent /foo [url][/url]

#

# Directives controlling the display of server-generated directory listings.

#

#

# IndexOptions: Controls the appearance of server-generated directory

# listings.

#

IndexOptions FancyIndexing VersionSort Name HTMLTable

#

# AddIcon* directives tell the server which icon to show for different

# files or filename extensions. These are only displayed for

# FancyIndexed directories.

#

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

linux

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjygw.html