Linux环境Apache服务器配置与管理_第1页
Linux环境Apache服务器配置与管理_第2页
Linux环境Apache服务器配置与管理_第3页
Linux环境Apache服务器配置与管理_第4页
Linux环境Apache服务器配置与管理_第5页
已阅读5页,还剩67页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Linux环境Apache服务器配置与管理一、Apache的安装首先使用下面的命令来查看系统是否已经安装了Apache可看到已经安装好了。另外也可以在终端窗口中执行来查看httpd程序是否在执行。下面介绍Apache服务器文件和目录WEB站点目录 描述/var/www Apache WEB站点文件的目录/var/www/html WEB站点的WEB文件/var/www/cgi-bin CGI程序文件/var/www/html/manual Apache WEB服务器手册/var/www/htmll/usage webalizer程序文件配置文件/etc/httpd/conf 基于目录的配置文件

2、,.htaccess文件包含对它所在目录中文件的访问控制指令/etc/httpd/conf/httpd.conf Apache WEB服务器配置文件目录/etc/httpd/conf/srm.conf 主要的Apache WEB服务器配置文件/etc/httpd/conf/access.conf 用来处理文档规范,配置文件类型昨未知的老式配置文件启动脚本/etc/rc.d/init.d/httpd WEB服务器守护进程的启动脚本/etc/rc.d/rc3.d/S85httpd 将运行级目录(/etc/rc3.d)连接到目录/etc/rc.d/init.d中的启动脚本应用文件/usr/sbin

3、Apache WEB服务器程序文件和应用程序的位置/usr/doc/ Apache WEB服务器文档/var/log/http Apache 日志文件的位置二、启动和运行Apache服务器其中一种是:另处一种是:httpd除了startstop命令之外,还有reload,condrestant,status命令,共6种状态三.启动系统时自动运行Apache若想让系统自动执行Apache,只需执行setup命令,进行Text Mode Setup Utility界面,选中System services中的:httpd服务即可. (源码网整理: HYPERLINK / )当然,还有一种更方便的图形

4、化方法.选择应用程序/系统设置/服务器设置/服务/四.httpd.conf文件详细和配置旧版中的srm.conf与access.conf文件的内容都被整合到httpd.conf文件中了.# Based upon the NCSA server configuration files originally by Rob McCool.# This is the main Apache server configuration file. It contains the# configuration directives that give the server its instructions.

5、# See for detailed information about# the directives.#这是Apache服务器主要配置文件。#它包含服务器的影响服务器运行的配置指令。#参见以取得关于这些指令的详细信息# Do NOT simply read the instructions in here without understanding# what they do. Theyre here only as hints or reminders. If you are unsure# consult the online docs. You have been warned. #

6、不要只是简单的阅读这些指令信息而不去理解它。#这里只是做了简单的说明,如果你没有参考在线文件,你就会被警告。# The configuration directives are grouped into three basic sections:# 1. Directives that control the operation of the Apache server process as a# whole (the global environment).# 2. Directives that define the parameters of the main or default se

7、rver,# which responds to requests that arent handled by a virtual host.# These directives also provide default values for the settings# of all virtual hosts.# 3. Settings for virtual hosts, which allow Web requests to be sent to# different IP addresses or hostnames and have them handled by the# same

8、 Apache server process.#这些配置指令被分为下面三个部分:#1. 控制整个Apache服务器行为的部分(即全局环境变量)#2. 定义主要或者默认服务参数的指令,也为所有虚拟主机提供默认的设置参数#3. 虚拟主机的设置参数# Configuration and logfile names: If the filenames you specify for many# of the servers control files begin with / (or drive:/ for Win32), the# server will use that explicit path

9、. If the filenames do *not* begin# with /, the value of ServerRoot is prepended - so logs/foo.log# with ServerRoot set to /etc/httpd will be interpreted by the# server as /etc/httpd/logs/foo.log.#配置和日志文件名:如果你指定的文件名以“/”开始(win32下以“dirver:/”),#服务器将使用绝对路径,如果文件名不是以“/”开始的,那么它将把ServerRoot#的值附加在文件名的前面,例如,对“

10、logs/foo.log,如果ServerRoot的值#为“/etc/httpd”,则该文件应为“/etc/httpd/logs/foo.log”# Section 1: Global Environment# The directives in this section affect the overall operation of Apache,# such as the number of concurrent requests it can handle or where it# can find its configuration files.#第一区:全局环境参数#这里设置的参数将

11、影响整个Apache服务器的行为;#例如Apache能够处理的并发请求的数量等。# ServerRoot: The top of the directory tree under which the servers# configuration, error, and log files are kept.#ServerRoot:指出服务器保存其配置、出错和日志文件等的根目录。# NOTE! If you intend to place this on an NFS (or otherwise network)# mounted filesystem then please read the

12、LockFile documentation# (available at );# you will save yourself a lot of trouble.# Do NOT add a slash at the end of the directory path.#ServerRoot /etc/httpd#注意!如果你想要将它指定为NFS或其它网络上的位置,#请一定要去阅读与LockFile有关的文档(可能在#)。#这将会使你自己也能解决很多问题。#路径的结尾不要添加斜线。#ServerRoot /etc/httpd# PidFile: The file in which the s

13、erver should record its process# identification number when it starts.#PidFile run/httpd.pid#串行访问的锁文件必须保存在本地磁盘上#PidFile:记录服务器启动进程号的文件。# Timeout: The number of seconds before receives and sends time out.#Timeout 120#Timeout:接收和发送前超时秒数#Timeout 120# KeepAlive: Whether or not to allow persistent connect

14、ions (more than# one request per connection). Set to Off to deactivate.#KeepAlive Off#KeepAlive:是否允许稳固的连接(每个连接有多个请求),#设为Off则停用。#KeepAlive Off# MaxKeepAliveRequests: The maximum number of requests to allow# during a persistent connection. Set to 0 to allow an unlimited amount.# We recommend you leave

15、 this number high, for maximum performance.#MaxKeepAliveRequests 100#MaxKeepAliveRequests:在稳固连接期间允许的最大请求数,#设为0表示无限制接入。#我们推荐你将其设为一个较大的值,以便提高性能MaxKeepAliveRequests 100# KeepAliveTimeout: Number of seconds to wait for the next request from the# same client on the same connection.#KeepAliveTimeout 15#Ke

16、epAliveTimeout:在同一个连接上从同一台客户上接收请求的秒数#KeepAliveTimeout 15# Server-Pool Size Regulation (MPM specific)# #Server-Pool大小设定(针对MPM的)# prefork MPM# StartServers: number of server processes to start# MinSpareServers: minimum number of server processes which are kept spare# MaxSpareServers: maximum number of

17、 server processes which are kept spare# ServerLimit: maximum value for MaxClients for the lifetime of the server# MaxClients: maximum number of server processes allowed to start# MaxRequestsPerChild: maximum number of requests a server process servesStartServers 8MinSpareServers 5MaxSpareServers 20S

18、erverLimit 256MaxClients 256MaxRequestsPerChild 4000# prefork MPM# StartServers:启动时服务器启动的进程数# MinSpareServers:保有的备用进程的最小数目# MaxSpareServers:保有的备用进程的最大数目# MaxClients:服务器允许启动的最大进程数# MaxRequestsPerChild:一个服务进程允许的最大请求数StartServers 8MinSpareServers 5MaxSpareServers 20MaxClients 256MaxRequestPerChild 4000

19、# worker MPM# StartServers: initial number of server processes to start# MaxClients: maximum number of simultaneous client connections# MinSpareThreads: minimum number of worker threads which are kept spare# MaxSpareThreads: maximum number of worker threads which are kept spare# ThreadsPerChild: con

20、stant number of worker threads in each server process# MaxRequestsPerChild: maximum number of requests a server process servesStartServers 2MaxClients 150MinSpareThreads 25MaxSpareThreads 75 ThreadsPerChild 25MaxRequestsPerChild 0# worker MPM# StartServers:服务器启动时的服务进程数目# MaxClients:允许同时连接的最大用户数目# Mi

21、nSpareThreads:保有的最小工作线程数目# MaxSpareThreads:允许保有的最大工作线程数目# ThreadsPerChild:每个服务进程中的工作线程常数# MaxRequestsPerChild:服务进程中允许的最大请求数目StartServers 2MaxClients 150MinSpareThreads 25MaxSpareThreads 75ThreadsPerChild 25MaxRequestsPerChild 0# Listen: Allows you to bind Apache to specific IP addresses and/or# port

22、s, in addition to the default. See also the # directive.# Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses ()#Listen 8:80Listen 80# Listen:允许你绑定Apache服务到指定的IP地址和端口上,以取代默认值# 参见指令# 使用如下命令使Apache只在指定的IP地址上监听,# 以防止它在IP地址上监听# List

23、en 8:80Listen 80# Dynamic Shared Object (DSO) Support# To be able to use the functionality of a module which was built as a DSO you# have to place corresponding LoadModule lines at this location so the# directives contained in it are actually available _before_ they are used.# Statically compiled mo

24、dules (those listed by httpd -l) do not need# to be loaded here.# Example:# LoadModule foo_module modules/mod_foo.so# 动态共享支持(DSO)# 为了能够使用那些以DSO模式编译的模块中的函数,你必须有相应的“LoadModule”行,# 因此,在这里包含了这些指令,以便能在使用它之前激活。# 那些静态编译的模块不需要在这里列出 (即以“httpd -l”列出的模块)# 示例:# LoadModule foo_module modules/mod_foo.so#LoadModul

25、e access_module modules/mod_access.soLoadModule auth_module modules/mod_auth.soLoadModule auth_anon_module modules/mod_auth_anon.soLoadModule auth_dbm_module modules/mod_auth_dbm.soLoadModule auth_digest_module modules/mod_auth_digest.soLoadModule ldap_module modules/mod_ldap.soLoadModule auth_ldap_

26、module modules/mod_auth_ldap.soLoadModule include_module modules/mod_include.soLoadModule log_config_module modules/mod_log_config.soLoadModule env_module modules/mod_env.soLoadModule mime_magic_module modules/mod_mime_magic.soLoadModule cern_meta_module modules/mod_cern_meta.soLoadModule expires_mo

27、dule modules/mod_expires.soLoadModule deflate_module modules/mod_deflate.soLoadModule headers_module modules/mod_headers.soLoadModule usertrack_module modules/mod_usertrack.soLoadModule setenvif_module modules/mod_setenvif.soLoadModule mime_module modules/mod_mime.soLoadModule dav_module modules/mod

28、_dav.soLoadModule status_module modules/mod_status.soLoadModule autoindex_module modules/mod_autoindex.soLoadModule asis_module modules/mod_asis.soLoadModule info_module modules/mod_info.soLoadModule dav_fs_module modules/mod_dav_fs.soLoadModule vhost_alias_module modules/mod_vhost_alias.soLoadModul

29、e negotiation_module modules/mod_negotiation.soLoadModule dir_module modules/mod_dir.soLoadModule imap_module modules/mod_imap.soLoadModule actions_module modules/mod_actions.soLoadModule speling_module modules/mod_speling.soLoadModule userdir_module modules/mod_userdir.soLoadModule alias_module mod

30、ules/mod_alias.soLoadModule rewrite_module modules/mod_rewrite.soLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule cache_module m

31、odules/mod_cache.soLoadModule suexec_module modules/mod_suexec.soLoadModule disk_cache_module modules/mod_disk_cache.soLoadModule file_cache_module modules/mod_file_cache.soLoadModule mem_cache_module modules/mod_mem_cache.soLoadModule cgi_module modules/mod_cgi.so# Load config files from the config

32、 directory /etc/httpd/conf.d.#Include conf.d/*.conf# ExtendedStatus controls whether Apache will generate full status# information (ExtendedStatus On) or just basic information (ExtendedStatus# Off) when the server-status handler is called. The default is Off.#ExtendedStatus On# ExtendedStatus:当调用“s

33、erver-status”时,控制Apache是产生“全”状态# 信息(ExtendedStatus On),还是产生基本信息(ExtendedStatus Off)。# 默认为off# ExtendedStatus On# Section 2: Main server configuration# The directives in this section set up the values used by the main# server, which responds to any requests that arent handled by a# definition. These

34、values also provide defaults for# any containers you may define later in the file.# All of these directives may appear inside containers,# in which case these default settings will be overridden for the# virtual host being defined.# 第二区:“主”服务配置# 这一区建立被 “主” 服务器用的指令值,以回应那些不被 # 定义处理的任何请求。# 这些数值也提供默认值给后

35、面定义的容器。# 如果中有定义,那么这里定义的指令值将被# 中的定义所覆盖。# If you wish httpd to run as a different user or group, you must run# httpd as root initially and it will switch. # User/Group: The name (or #number) of the user/group to run httpd as.# . On SCO (ODT 3) use User nouser and Group nogroup.# . On HPUX you may not

36、be able to use shared memory as nobody, and the# suggested workaround is to create a user www and use that user.# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)# when the value of (unsigned)Group is above 60000; # dont use Group #-1 on these systems!#User apacheGroup apache# 如果你想使

37、httpd以另外的用户或组来运行,你必须在开始时以root方式启动# 然后再将它切换为你想要使用的用户或组。# User/Group:运行httpd的用户和组# 在SCO (ODT3)上使用“User nouser”和“Group nogroup”# 在HPUX上,你可能不能以nobody身份使用共享内存,建议创建一个www用户。# 注意一些核心(kernel)在组ID大于60000时拒绝setgid(Group)或semctl(IPC_SET),# 建议在这些系统上不要使用“Group #-1”。#User apacheGroup apache# ServerAdmin: Your addr

38、ess, where problems with the server should be# e-mailed. This address appears on some server-generated pages, such# as error documents. e.g. HYPERLINK mailto:adminadmin#ServerAdmin HYPERLINK mailto:rootlocalhostrootlocalhost# ServerAdmin:你的邮件地址,当发生问题时Apache将向你发出邮件。# 作为一个出错文档,这个地址显示在server-generated页

39、上,# 例如:HYPERLINK mailto:adminadmin#ServerAdmin HYPERLINK mailto:rootlocalhostrootlocalhost# 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 thi

40、s is not set to valid DNS name for your host, server-generated# redirections will not work. See also the UseCanonicalName directive.# If your host doesnt 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 i

41、n a sensible way.#ServerName :80# ServerName指定Apache用于识别自身的名字和端口号。# 通常这个值是自动指定的,但是我们推荐你显式的指定它以防止启动时出错# 如果你为你的主机指定了一个无效的DNS名,server-generated重定向将不能工作。# 参见UseCanonicalName指令# 如果你的主机没有注册DNS名,在这里键入它的IP地址# 无论如何,你必须使用它的IP地址来提供服务,# 这里使用一种容易理解的方式重定向服务ServerName :80# UseCanonicalName: Determines how Apache c

42、onstructs 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# UseCanonicalName:决定Apache如何构造URLS和 SERVER_NAME 和 S

43、ERVER_PORT 的指令。# 当设置为 “Off”时,Apache会使用用户端提供的主机名和端口号。# 当设置为“On”,Apache会使用ServerName指令的值。#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

44、 locations.#DocumentRoot /var/www/html# DocumentRoot:你的文档的根目录。默认情况下,所有的请求从这个目录进行应答。# 但是可以使用符号链接和别名来指向到其他的位置。#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 su

45、bdirectories). # First, we configure the default to be a very restrictive set of # features. # Options FollowSymLinks AllowOverride None# Apache可以存取的每个目录都可以配置存取权限(包括它的子目录)。# 首先,我们配置一个高限制的特征。# 这将禁止访问文件系统所在的目录,并添加你希望允许访问的目录块。# 如下所示Order Deny,AllowDeny from all# Note that from this point forward you mu

46、st specifically allow# particular features to be enabled - so if somethings not working as# you might expect, make sure that you have specifically enabled it# below.# 注意从这里开始你一定要明确地允许哪些特别的特征能够被使用。# - 所以,如果Apache没有象你所期待的那样工作的话,# 请检查你是否在下面明确的指定它可用。# This should be changed to whatever you set DocumentR

47、oot to.# 这将改变到你设置的DocumentRoot# 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# doesnt give it to you.# The Options directive is bot

48、h complicated and important. Please see# HYPERLINK /docs-2.0/mod/core.html l optionsurl/docs-2.0/mod/core.html#options/url# for more information.# Options Indexes FollowSymLinks# Options:这个指令的值可以是“None”,“All”,或者下列选项的任意组合:# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews# 注意,“

49、MultiViews”必须被显式的指定,“Options All”不能为你提供这个特性。# 这个指令既复杂又重要,请参见#“url/docs-2.0/mod/core.html#optioins/url”以取得更多的信息。#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 AuthCon

50、fig Limit# AllowOverride None# AllowOverride控制那些被放置在.htaccess文件中的指令。# 它可以是“All”,“None”,或者下列指令的组合:# Options FileInfo AuthConfig Limit#AllowOverride None# Controls who can get stuff from this server.# Order allow,deny Allow from all# 控制谁可以获得服务。#Order allow,denyAllow from all# UserDir: The name of the

51、directory that is appended onto a users home# directory if a user request is received.# UserDir:指定在得到一个user请求时将会添加到用户home目录后的目录名。# UserDir: The name of the directory that is appended onto a users home# directory if a user request is received.# The path to the end user account public_html directory m

52、ust 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: HYPERLINK /

53、docs/misc/FAQ.html l forbiddenurl/docs/misc/FAQ.html#forbidden/url# # # 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 users public_html # dire

54、ctory, remove the UserDir disable line above, and uncomment # the following line instead: # #UserDir public_html# Control access to UserDir directories. The following is an example# for a site where these directories are restricted to read-only.# AllowOverride FileInfo AuthConfig Limit# Options Mult

55、iViews Indexes SymLinksIfOwnerMatch IncludesNoExec# # Order allow,deny# Allow from all# # # Order deny,allow# Deny from all# # 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. T

56、he MultiViews Option can be used for the # same purpose, but it is much slower.#DirectoryIndex index.html index.html.var# DirectoryIndex:定义请求是一个目录时,Apache向用户提供服务的文件名# index.html.var文件(一个类型映象文件)用于提供一个文档处理列表,# 出于同样的目的,也可以使用MultiViews选项,但是它会非常慢。#DirectoryIndex index.html index.html.var# AccessFileName:

57、 The name of the file to look for in each directory# for additional configuration directives. See also the AllowOverride# directive.#AccessFileName .htaccess# AccessFileName:在每个目录中查询为目录提供附加配置指令的文件的文件名。# 参见AllowOverride指令。#AccessFileName .htaccess# The following lines prevent .htaccess and .htpasswd

58、files from being # viewed by Web clients. # Order allow,deny Deny from all# 下面的行防止.htaccess和.htpasswd文件被Web客户查看。#Order allow,denyDeny from all# TypesConfig describes where the mime.types file (or equivalent) is# to be found.#TypesConfig /etc/mime.types# Typeconfig:定义在哪里查询mime.types文件。#TypeConfig con

59、f/mime.types# 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#

60、 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.#DefaultType text/plain# DefaultType:定义当不能确定MIME类型时服务器提供的默认MIME类型。# 如果你的服务主要包含text或HTML文档,“text/plain”是一个好的选择;# 如果大多是二进制文档,诸如软件或图像,你应使用# “application/octer-

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论