Linux全攻略--Apache服务器配置与管理(一)一、Apache的安装首先使用下面的命令来查看系统是否已经安装了Apache可看到已经安装好了。另外也可以在终端窗口中执行来查看httpd程序是否在执行。下面介绍Apache服务器文件和目录WEB站点目录描述/var/站点文件的目录/var/站点的WEB文件/var/程序文件/var/服务器手册/var/程序文件配置文件/etc/httpd/conf基于目录的配置文件,.htaccess文件包含对它所在目录中文件的访问控制指令/etc/httpd/conf/httpd.confApacheWEB服务器配置文件目录/etc/httpd/conf/srm.conf主要的ApacheWEB服务器配置文件/etc/httpd/conf/access.conf用来处理文档规范,配置文件类型昨未知的老式配置文件启动脚本/etc/rc.d/init.d/httpdWEB服务器守护进程的启动脚本/etc/rc.d/rc3.d/S85httpd将运行级目录(/etc/rc3.d)连接到目录/etc/rc.d/init.d中的启动脚本应用文件/usr/sbinApacheWEB服务器程序文件和应用程序的位置/usr/doc/ApacheWEB服务器文档/var/log/httpApache日志文件的位置二、启动和运行Apache服务器其中一种是:另处一种是:httpd除了start\stop命令之外,还有reload,condrestant,status命令,共6种状态三.启动系统时自动运行Apache若想让系统自动执行Apache,只需执行setup命令,进行TextModeSetupUtility界面,选中Systemservices中的:httpd服务即可.当然,还有一种更方便的图形化方法.选择应用程序/系统设置/服务器设置/服务/四.httpd.conf文件详细和配置旧版中的srm.conf与access.conf文件的内容都被整合到httpd.conf文件中了.##BasedupontheNCSAserverconfigurationfilesoriginallybyRobMcCool.##ThisisthemainApacheserverconfigurationfile.Itcontainsthe#configurationdirectivesthatgivetheserveritsinstructions.#SeeURL:[url][/url]fordetailedinformationabout#thedirectives.###这是Apache服务器主要配置文件。#它包含服务器的影响服务器运行的配置指令。#参见以取得关于这些指令的详细信息##DoNOTsimplyreadtheinstructionsinherewithoutunderstanding#whattheydo.They'rehereonlyashintsorreminders.Ifyouareunsure#consulttheonlinedocs.Youhavebeenwarned.##不要只是简单的阅读这些指令信息而不去理解它。#这里只是做了简单的说明,如果你没有参考在线文件,你就会被警告。##Theconfigurationdirectivesaregroupedintothreebasicsections:#1.DirectivesthatcontroltheoperationoftheApacheserverprocessasa#whole(the'globalenvironment').#2.Directivesthatdefinetheparametersofthe'main'or'default'server,#whichrespondstorequeststhataren'thandledbyavirtualhost.#Thesedirectivesalsoprovidedefaultvaluesforthesettings#ofallvirtualhosts.#3.Settingsforvirtualhosts,whichallowWebrequeststobesentto#differentIPaddressesorhostnamesandhavethemhandledbythe#sameApacheserverprocess.##这些配置指令被分为下面三个部分:#1.控制整个Apache服务器行为的部分(即全局环境变量)#2.定义主要或者默认服务参数的指令,也为所有虚拟主机提供默认的设置参数#3.虚拟主机的设置参数##Configurationandlogfilenames:Ifthefilenamesyouspecifyformany#oftheserver'scontrolfilesbeginwith/(ordrive:/forWin32),the#serverwillusethatexplicitpath.Ifthefilenamesdo*not*begin#with/,thevalueofServerRootisprepended--sologs/foo.log#withServerRootsetto/etc/httpdwillbeinterpretedbythe#serveras/etc/httpd/logs/foo.log.##配置和日志文件名:如果你指定的文件名以“/”开始(win32下以“dirver:/”),#服务器将使用绝对路径,如果文件名不是以“/”开始的,那么它将把ServerRoot#的值附加在文件名的前面,例如,对“logs/foo.log,如果ServerRoot的值#为“/etc/httpd”,则该文件应为“/etc/httpd/logs/foo.log”####Section1:GlobalEnvironment##ThedirectivesinthissectionaffecttheoveralloperationofApache,#suchasthenumberofconcurrentrequestsitcanhandleorwhereit#canfinditsconfigurationfiles.###第一区:全局环境参数##这里设置的参数将影响整个Apache服务器的行为;#例如Apache能够处理的并发请求的数量等。##ServerRoot:Thetopofthedirectorytreeunderwhichtheserver's#configuration,error,andlogfilesarekept.##ServerRoot:指出服务器保存其配置、出错和日志文件等的根目录。##NOTE!IfyouintendtoplacethisonanNFS(orotherwisenetwork)#mountedfilesystemthenpleasereadtheLockFiledocumentation#(availableatURL:[url][/url]);#youwillsaveyourselfalotoftrouble.##DoNOTaddaslashattheendofthedirectorypath.#ServerRoot/etc/httpd#注意!如果你想要将它指定为NFS或其它网络上的位置,#请一定要去阅读与LockFile有关的文档(可能在#)。#这将会使你自己也能解决很多问题。##路径的结尾不要添加斜线。#ServerRoot/etc/httpd#PidFile:Thefileinwhichtheservershouldrecorditsprocess#identificationnumberwhenitstarts.#PidFilerun/httpd.pid##串行访问的锁文件必须保存在本地磁盘上##PidFile:记录服务器启动进程号的文件。##Timeout:Thenumberofsecondsbeforereceivesandsendstimeout.#Timeout120#Timeout:接收和发送前超时秒数#Timeout120##KeepAlive:Whetherornottoallowpersistentconnections(morethan#onerequestperconnection).SettoOfftodeactivate.#KeepAliveOff##KeepAlive:是否允许稳固的连接(每个连接有多个请求),#设为Off则停用。#KeepAliveOff#MaxKeepAliveRequests:Themaximumnumberofrequeststoallow#duringapersistentconnection.Setto0toallowanunlimitedamount.#Werecommendyouleavethisnumberhigh,formaximumperformance.#MaxKeepAliveRequests100##MaxKeepAliveRequests:在稳固连接期间允许的最大请求数,#设为0表示无限制接入。#我们推荐你将其设为一个较大的值,以便提高性能MaxKeepAliveRequests100##KeepAliveTimeout:Numberofsecondstowaitforthenextrequestfromthe#sameclientonthesameconnection.#KeepAliveTimeout15##KeepAliveTimeout:在同一个连接上从同一台客户上接收请求的秒数#KeepAliveTimeout15####Server-PoolSizeRegulation(MPMspecific)######Server-Pool大小设定(针对MPM的)###preforkMPM#StartServers:numberofserverprocessestostart#MinSpareServers:minimumnumberofserverprocesseswhicharekeptspare#MaxSpareServers:maximumnumberofserverprocesseswhicharekeptspare#ServerLimit:maximumvalueforMaxClientsforthelifetimeoftheserver#MaxClients:maximumnumberofserverprocessesallowedtostart#MaxRequestsPerChild:maximumnumberofrequestsaserverprocessservesIfModuleprefork.cStartServers8MinSpareServers5MaxSpareServers20ServerLimit256MaxClients256MaxRequestsPerChild4000/IfModule#preforkMPM#StartServers:启动时服务器启动的进程数#MinSpareServers:保有的备用进程的最小数目#MaxSpareServers:保有的备用进程的最大数目#MaxClients:服务器允许启动的最大进程数#MaxRequestsPerChild:一个服务进程允许的最大请求数StartServers8MinSpa