仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 841|回复: 9
打印 上一主题 下一主题

[CentOS(社区)] 给大家带来CentOS办事器下Web办事httpd设置参数具体先容

[复制链接]
深爱那片海 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 20:41:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
欢迎大家来到仓酷云论坛!1、设置文件和基础格局
设置文件路径:/etc/httpd/conf/httpd.conf
设置参数值
1、设置指令不辨别字符巨细写;可是值有大概辨别字符巨细写
2、有些指令能够反复呈现屡次
设置文件格局:
1、全局设置
2、主机设置:用于仅供应一个站点
3、假造主机:用于供应多个站点(和主机设置不克不及同时失效)
设置文件语法测试:{servicehttpdconfigtest|httpd-t}


2、具体设置
1、监听套接字
#设置文件事例
#Listen12.34.56.78:80
Listen80
Listen8080
Listen192.168.1.110:8082



此指令能够呈现屡次;用于指定监听多个分歧的套接字:
[Linux]#httpd-t
SyntaxOK
[Linux]#servicehttpdreload
Reloadinghttpd:

[Linux]#ss-tnl
StateRecv-QSend-QLocalAddress:PortPeerAddress:Port
LISTEN0128:::111:::*
LISTEN0128*:111*:*
LISTEN0128:::8080:::*
LISTEN0128:::80:::*
LISTEN0128192.168.1.186:8082*:*




2、设置利用KeepAlive
#KeepAlive:Whetherornottoallowpersistentconnections(morethan
#onerequestperconnection).Setto"Off"todeactivate.
#
#KeepAliveOn
KeepAliveOff
MaxKeepAliveRequests100#耐久毗连最年夜哀求数
KeepAliveTimeout15#超不时间




3、多道处置模块MPM
检察体系默许启用的模块
[Linux]#httpd-l
Compiledinmodules:
core.c
prefork.c#默许启用prefork模块
http_core.c
mod_so.c
[Linux]#
#如需启用worker模块;必要变动设置文件
[Linux]#vi/etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.worker#启用该项后重启httpd



设置模块信息
[Linux]#vi/etc/httpd/conf/httpd.conf
#preforkMPM
#StartServers:numberofserverprocessestostart
#MinSpareServers:minimumnumberofserverprocesseswhicharekeptspare
#MaxSpareServers:maximumnumberofserverprocesseswhicharekeptspare
#ServerLimit:maximumvalueforMaxClientsforthelifetimeoftheserver
#MaxClients:maximumnumberofserverprocessesallowedtostart
#MaxRequestsPerChild:maximumnumberofrequestsaserverprocessserves
prefork不乱性较好,一个线程溃散不会影响其他线程
<IfModuleprefork.c>判别prefork模块是不是存在
StartServers8默许启动的事情历程数;不包括主历程
MinSpareServers5起码余暇历程数
MaxSpareServers20最年夜余暇历程数
ServerLimit256最年夜举动历程数
MaxClients256最多同意倡议的哀求的个数
MaxRequestsPerChild4000每一个子历程在性命周期内所可以办事的最多哀求个数
</IfModule>
#workerMPM
#StartServers:initialnumberofserverprocessestostart
#MaxClients:maximumnumberofsimultaneousclientconnections
#MinSpareThreads:minimumnumberofworkerthreadswhicharekeptspare
#MaxSpareThreads:maximumnumberofworkerthreadswhicharekeptspare
#ThreadsPerChild:constantnumberofworkerthreadsineachserverprocess
#MaxRequestsPerChild:maximumnumberofrequestsaserverprocessserves
worker多个历程;一个历程溃散会影响其下的其他线程
<IfModuleworker.c>判别worker模块是不是存在
StartServers4启动的子历程的个数
MaxClients300并发哀求的最年夜个数
MinSpareThreads25起码余暇线程数
MaxSpareThreads75最年夜余暇线程数
ThreadsPerChild25每一个子历程可天生的线程数
MaxRequestsPerChild0每一个子历程在性命周期内所可以办事的最多哀求个数;0暗示不做限制
</IfModule>



4、DSO模块的加载体例
LoadModulemodule_name/path/to/module
可使用绝对路径和相对路径;绝对路径则关于ServerRoot所界说的地位而言;
变动完成后servicehttpdreload可失效
#LoadModulefoo_modulemodules/mod_foo.so
#
LoadModuleauth_basic_modulemodules/mod_auth_basic.so
LoadModuleauth_digest_modulemodules/mod_auth_digest.so
LoadModuleauthn_file_modulemodules/mod_authn_file.so
LoadModuleauthn_alias_modulemodules/mod_authn_alias.so
LoadModuleauthn_anon_modulemodules/mod_authn_anon.so
#
#
[Linux]#httpd-M#能够检察体系一切装载模块
LoadedModules:
core_module(static)
mpm_prefork_module(static)
http_module(static)
so_module(static)
auth_basic_module(shared)
auth_digest_module(shared)
authn_file_module(shared)
authn_alias_module(shared)




5、设置站点根目次和页面属性
#DocumentRoot:Thedirectoryoutofwhichyouwillserveyour
#documents.Bydefault,allrequestsaretakenfromthisdirectory,but
#symboliclinksandaliasesmaybeusedtopointtootherlocations.
#
DocumentRoot"/var/www/html"
DocumentRoot"/path/to/somewhere(站点路径)"#格局
#TheOptionsdirectiveisbothcomplicatedandimportant.Pleasesee下述站点有设置具体申明
#http://httpd.apache.org/docs/2.2/mod/core.html#options
#formoreinformation.
#
<Directory"/var/www/html">#页面会见属性
#
#
OptionsIndexesFollowSymLinks
#
#
#
Indexes短少默许页面时;同意将目次中的一切文件已列表情势前往给用户
FollowSymLinks同意跟从标记链接所指向的原始文件;伤害
None一切都不启用
All一切都启用
ExecCGI是不是同意利用mod_cgi模块实行CGI剧本
Includes是不是同意利用mod_include模块完成办事器端包括(SSI)
MultiViews同意利用mod_negotiation完成内容协商
SymLinksIfOwnerMatch在链接文件属主属组与原始文件的属主属组不异时;同意跟从标记链接所指向的原始文件
#
#
#AllowOverridecontrolswhatdirectivesmaybeplacedin.htaccessfiles.
#Itcanbe"All","None",oranycombinationofthekeywords:
#OptionsFileInfoAuthConfigLimit
基于主机的会见把持
#
#
AllowOverrideNone暗示上面这些把持机制是不是被禁用;None暗示不被禁用
#
#Controlswhocangetstufffromthisserver.
#
#allow同意;deny不同意
Orderallow,deny#默许deny;没有allow的都deny;能够写多条;自上而下婚配
Allowfromall格局:fromIP
Deny
#两者都婚配或两者都无婚配项时,则今后者为准;不然,则以婚配到的为准
</Directory>
#最好婚配:从列表中找出最小的能婚配到会见者的地点的条目为终极是失效的
#具体参考http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow




6、界说默许主页面
#Theindex.html.varfile(atype-map)isusedtodelivercontent-
#negotiateddocuments.TheMultiViewsOptioncanbeusedforthe
#samepurpose,butitismuchslower.
#
DirectoryIndexindex.htmlindex.html.var#自左而右顺次查找




7、用户目次
#Thepathtotheenduseraccountpublic_htmldirectorymustbe
#accessibletothewebserveruserid.Thisusuallymeansthat~userid
权限申明
#musthavepermissionsof711,~userid/public_htmlmusthavepermissions
#of755,anddocumentscontainedthereinmustbeworld-readable.
#Otherwise,theclientwillonlyreceivea"403Forbidden"message.
#
#Seealso:http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
<IfModulemod_userdir.c>
#
#UserDirisdisabledbydefaultsinceitcanconfirmthepresence
#ofausernameonthesystem(dependingonhomedirectory
#permissions).
#
UserDirdisabled
disabled克制
UserDirpublic_html用户家目次下的目次称号,一切位于此目次中的文件都可经由过程前述的会见路径举行会见;用户的家目次的付与运转httpd历程的用户具有实行权限;
#
#Toenablerequeststo/~user/toservetheuserspublic_html
#directory,removethe"UserDirdisabled"lineabove,anduncomment
#thefollowinglineinstead:
#
#UserDirpublic_html
</IfModule>




8、设置日记功效
/var/log/httpd/access.log&&error.log
access.log:其必要纪录的内容必要自界说
会见日记:
CustomLog"/path/to/access_log_file"Format_Name
LogFormatFormat_StringFormat_Nam
#Thefollowingdirectivesdefinesomeformatnicknamesforusewith
#aCustomLogdirective(seebelow).
#
LogFormat"%h%l%u%t"%r"%>s%b"%{Referer}i""%{User-Agent}i""combined
LogFormat"%h%l%u%t"%r"%>s%b"common
LogFormat"%{Referer}i->%U"referer
LogFormat"%{User-agent}i"agent
#
#
#
%h:客户端地点
%l:近程登录名;一般为-
%u:认证时的近程用户名;一般为-
%t:承受到哀求时的工夫;
%r:哀求报文的肇端行;
%>s:呼应形态码;
%b:呼应报文的长度;单元字节;不包括HTTP首部
%{Header_Name}i:纪录指定哀求报文首部的内容(value)
%U:哀求的URL;不包括其他任何哀求串
#
#详细请参照http://httpd.apache.org/docs/2.2/mod/mod_log_config.html
#
#ErrorLog:Thelocationoftheerrorlogfile.
#IfyoudonotspecifyanErrorLogdirectivewithina<VirtualHost>
#container,errormessagesrelatingtothatvirtualhostwillbe
#loggedhere.Ifyou*do*defineanerrorlogfilefora<VirtualHost>
#container,thathostserrorswillbeloggedthereandnothere.
#
ErrorLoglogs/error_log




9、路径别号和默许字符集
Alias/alias/"/path/to/somewhere/":后面别号开头有/前面开头就必定得有/
#Weincludethe/icons/aliasforFancyIndexeddirectorylistings.Ifyou
#donotuseFancyIndexing,youmaycommentthisout.
#
Alias/icons/"/var/www/icons/"
#
#
#字符集
#Specifyadefaultcharsetforallcontentserved;thisenables
#interpretationofallcontentasUTF-8bydefault.Tousethe
#defaultbrowserchoice(ISO-8859-1),ortoallowtheMETAtags
#inHTMLcontenttooverridethischoice,commentoutthis
#directive:
#
AddDefaultCharsetUTF-8





10、CGI剧本路径别号
URL-->FileSystemDirectory
CGI:CommonGatewayInte***ce
有良多机制必要SUID或SGID权限;
httpd没法间接实行剧本;基于CGI协定挪用剧本注释器;守候剧本注释器前往了局到web办事器
#ScriptAlias:Thiscontrolswhichdirectoriescontainserverscripts.
#ScriptAliasesareessentiallythesameasAliases,exceptthat
#documentsintherealnamedirectoryaretreatedasapplicationsand
#runbytheserverwhenrequestedratherthanasdocumentssenttotheclient.
#Thesamerulesabouttrailing"/"applytoScriptAliasdirectivesasto
#Alias.
#
ScriptAlias/cgi-bin/"/var/www/cgi-bin/"
ScriptAlias/URL/"/path/to/somewhere/"#格局;路径必要实行权限
#
#测试
cat<<EOF
Content-Type:text/html
<pre>
Thehostnameis:`hostname`.
Thetimeis:`date`.
</pre>
EOF




11、基于用户的会见把持
假造用户:不是体系的账号暗码;
在设置文件LoadModule下(auth)开首的认证范例:
basic:基础认证;账号和密钥明文发送;
digest:择要认证;hash编程以后发送
认证供应者(authenticationprovider):账号和密钥的寄存地位(authn)
受权机制(authentication):依据甚么举行受权(authz)
1、编纂设置文件利用:
[Linux]#vi/etc/httpd/conf/httpd.conf
#在<Directory>网站四周下找一个地位新建一个
<Directory"/var/www/html/fin">#指定目次文件
OptionsNone#没有任何选项
AllowOverrideAuthConfig#利用认证设置
AuthTypeBasic#认证范例
AuthName"PrivateArea"#质询时窗口题目
#AuthBasicProviderfile#认证供应者;默许为文件
AuthUserFile/etc/httpd/conf/.htpasswd#指定文件寄存用户账号
#AuthGroupFile/etc/httpd/conf/.htgroup#指定文件寄存组
#RequiregroupGroupName#指定组名
Requirevalid-user#一切的正当账户
</Directory>



2、利用htpasswd下令天生认证库
[Linux]#htpasswd-b/etc/httpd/conf/.htpasswdpipipipi
Addingpasswordforuserpipi
[Linux]#
具体参数能够manhtpasswd
SYNOPSIS
htpasswd[-c][-m][-D]passwdfileusername
htpasswd-b[-c][-m|-d|-p|-s][-D]passwdfileusernamepassword
htpasswd-n[-m|-d|-s|-p]username
htpasswd-nb[-m|-d|-s|-p]usernamepassword





12、假造主机
一个物理办事器供应多个站点;利用假造主机得先作废中央主机
1、基于分歧的IP完成分歧的假造

利用分歧IP;
2、基于分歧的port完成分歧的假造主机
利用分歧端口
3、基于分歧的FQDN完成分歧的假造主机
利用分歧的ServerName的值:FQDN

#DocumentRoot:Thedirectoryoutofwhichyouwillserveyour
#documents.Bydefault,allrequestsaretakenfromthisdirectory,but
#symboliclinksandaliasesmaybeusedtopointtootherlocations.
#
#DocumentRoot"/var/www/html"#这项必要先正文;中央主机
#
#基于主机名分歧举行测试;上面这项必要开启;IP和port是不必要开启的
NameVirtualHost*:80
#
#NOTE:NameVirtualHostcannotbeusedwithoutaportspecifier
#(e.g.:80)ifmod_sslisbeingused,duetothenatureofthe
#SSLprotocol.
#
#VirtualHostexample:
#AlmostanyApachedirectivemaygointoaVirtualHostcontainer.
#ThefirstVirtualHostsectionisusedforrequestswithoutaknown
#servername.
#
<VirtualHost*:80>
ServerAdminwebmaster@pipi.com
DocumentRoot/var/www/docs/pipi#指定站点路径
ServerNamewww.pipi.com#指定FQDN
ErrorLoglogs/pipi.com-error_log#指定毛病日记路径及称号
CustomLoglogs/pipi.com-access_logcommon#指定会见日记路径及称号
</VirtualHost>
<VirtualHost*:80>
ServerAdminwebmaster@soul.org
DocumentRoot/var/www/docs/soul
ServerNamewww.soul.org
ErrorLoglogs/soul.org-error_log
CustomLoglogs/soul.org-access_logcommon
</VirtualHost>
<VirtualHost*:80>
ServerAdminwebmaster@dark.net
DocumentRoot/www/docs/dark
ServerNamewww.dark.net
ErrorLoglogs/dark.net-error_log
CustomLoglogs/dark.net-access_logcommon
</VirtualHost>
#
#设置完成后必要在对应的路径下创建响应的文件
[Linux]#httpd-t
SyntaxOK
[Linux]#servicehttpdrestart
Stoppinghttpd:[OK]
Startinghttpd:[OK]
[Linux]#



设置完成后如在linux下测试则修正/etc/hosts文件;windows下修正C:WindowsSystem32driversetchosts文件

<divclass="syntaxhighlighterbashie"id="highlighter_729748"><divclass="container">X.X.X.129www.pipi.com
<divclass="linenumber2index1alt1">如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!
冷月葬花魂 该用户已被删除
沙发
发表于 2015-1-16 21:20:01 来自手机 | 只看该作者

给大家带来CentOS办事器下Web办事httpd设置参数具体先容

把这个问题放在其他Linux社区请求帮助也是一种选择。如果Linux得不到答案,请不要以为我们觉得无法帮助你。有时只是看到你问题的人不知道答案罢了。这时换一个社区是不错的选择。
板凳
发表于 2015-1-20 21:07:54 | 只看该作者
有疑问前,知识学习前,先用搜索。
金色的骷髅 该用户已被删除
地板
发表于 2015-1-30 05:39:59 | 只看该作者
再次,Linux是用C语言编写的,我们有学习C语言的基础,读程序和编写代码方面存在的困难小一点,也是我们能较快掌握的原因之一。?
再现理想 该用户已被删除
5#
发表于 2015-2-6 08:29:41 | 只看该作者
清楚了解网络的基础知识,特别是在Linux下应用知识,如接入internet等等。
蒙在股里 该用户已被删除
6#
发表于 2015-2-15 22:02:49 | 只看该作者
选择一些适于初学者的Linux社区。
山那边是海 该用户已被删除
7#
发表于 2015-3-4 15:35:38 | 只看该作者
一定要养成在命令行下工作的习惯,要知道X-window只是运行在命令行模式下的一个应用程序。在命令行下学习虽然一开始进度较慢。
小妖女 该用户已被删除
8#
发表于 2015-3-11 20:28:41 | 只看该作者
掌握硬件配置,如显卡,声卡,网卡等,硬件只要不是太老或太新一般都能被支持,作为一名Linux系统管理员建议多阅读有关硬件配置文章,对各种不支持或支持不太好的硬件有深刻的了解。
简单生活 该用户已被删除
9#
发表于 2015-3-19 14:39:29 | 只看该作者
工具书对于学习者而言是相当重要的。一本错误观念的工具书却会让新手整个误入歧途。目前国内关于Linux的书籍有很多不过精品的不多。
透明 该用户已被删除
10#
发表于 2015-3-29 03:17:31 | 只看该作者
用户下达的命令解释给系统去执行,并将系统传回的信息再次解释给用户,估shell也称为命令解释器,有关命令的学习可参考论坛相关文章,精通英文也是学习Linux的关键。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-3 13:09

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表