📄 apache安装笔记.doc
字号:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="APACHE安装笔记.files/filelist.xml">
<title>欢迎来到LinuxKit.com!!</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>Lee</o:Author>
<o:Template>Normal</o:Template>
<o:LastAuthor>Lee</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>1</o:TotalTime>
<o:Created>2004-10-06T06:36:00Z</o:Created>
<o:LastSaved>2004-10-06T06:37:00Z</o:LastSaved>
<o:Pages>5</o:Pages>
<o:Words>1433</o:Words>
<o:Characters>8170</o:Characters>
<o:Company>Lee</o:Company>
<o:Lines>68</o:Lines>
<o:Paragraphs>19</o:Paragraphs>
<o:CharactersWithSpaces>9584</o:CharactersWithSpaces>
<o:Version>10.4219</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:Compatibility>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<link rel=Stylesheet type="text/css" media=all href="inc/MAIN.CSS">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:宋体;
mso-bidi-font-family:宋体;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]-->
</head>
<script language="JavaScript" type="text/JavaScript">
function validate(theform) {
if (theform.Content.value=="" || theform.Title.value=="") {
alert("请填写评论的内容.");
return false; }
}
</script>
<style type="text/css">
<!--
.stedit {
BORDER-BOTTOM: #4a3163 1px solid;
BORDER-LEFT: #4a3163 1px solid;
BORDER-RIGHT: #4a3163 1px solid;
BORDER-TOP: #4a3163 1px solid;
FONT-SIZE: 9pt;
}
.table1 {
BORDER-BOTTOM: #7D7D7D 1px solid; BORDER-LEFT: #7D7D7D 0px solid; BORDER-RIGHT: #7D7D7D 0px solid; BORDER-TOP: #7D7D7D 1px solid
}
-->
</style>
<body bgcolor=white background="image/bg.gif" lang=ZH-CN link=blue vlink=blue
style='tab-interval:21.0pt' leftmargin=0 topmargin=0>
<div class=Section1>
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
style='mso-cellspacing:0cm;background:white;mso-padding-alt:0cm 0cm 0cm 0cm'>
<tr style='mso-yfti-irow:0;mso-yfti-lastrow:yes;height:203.25pt'>
<td width=645 valign=top style='width:483.95pt;padding:0cm 0cm 0cm 0cm;
height:203.25pt'>
<p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p>
<table class=MsoNormalTable border=0 cellpadding=0 width="100%"
style='width:100.0%;mso-cellspacing:1.5pt' background="image/point.gif">
<tr style='mso-yfti-irow:0;mso-yfti-lastrow:yes;height:26.25pt'>
<td style='padding:.75pt .75pt .75pt .75pt;height:26.25pt'>
<p class=MsoNormal align=center style='text-align:center'><strong><span
lang=EN-US style='font-family:宋体;mso-bidi-font-family:宋体;color:black'>APACHE安装笔记</span></strong>
</p>
</td>
</tr>
</table>
<p class=MsoNormal><span lang=EN-US style='display:none;mso-hide:all'><o:p> </o:p></span></p>
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width="95%"
style='width:95.0%;mso-cellspacing:0cm;mso-padding-alt:0cm 0cm 0cm 0cm'>
<tr style='mso-yfti-irow:0;mso-yfti-lastrow:yes;height:285.0pt'>
<td valign=top style='padding:0cm 0cm 0cm 0cm;height:285.0pt'>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='color:#594802'>内容摘要:<span
lang=EN-US><br>
<br>
从简化安装==>性能调优==>方便维护的角度,讨论WEB服务的规划==>HTTPD安装/应用模块配置==>升级/维护等过程。<br>
让APACHE的升级和PHP RESIN等应用模块的升级完全互不影响。<br>
<br>
WEB应用容量规划:根据硬件配置和WEB应用的特点进行WEB服务的规划及一些简单的估算公式; <br>
APACHE安装过程:apache的通用的简化安装选项,方便以后的应用的模块化配置;<br>
修改 HARD_SERVER_LIMIT:<br>
vi /path/to/<span class=SpellE>apache_src/src/include/httpd.h</span><br>
#define HARD_SERVER_LIMIT 2560 <===将原来的 HARD_SERVER_LIMIT 256 后面加个“0”<br>
apache编译:<br>
/path/to/<span class=SpellE>apache_src</span>/configure --prefix=/<span
class=SpellE>another_driver</span>/apache --enable-shared=max
--enable-module=most <br>
可选应用模块/工具的安装:<span class=SpellE>php</span> resin <span class=SpellE>mod_gzip</span>
<span class=SpellE>mod_expire</span>及各个模块之间的配合;<br>
PHP安装:<br>
/path/to/<span class=SpellE>php_src</span>/configure --with-<span
class=SpellE>apxs</span>=/path/to/apache/bin/<span class=SpellE>apxs</span>
--enable-track-<span class=SpellE>vars</span> --with-other-modules-you-need<br>
<span class=SpellE>mod_resin</span>安装:<br>
/path/to/resin/<span class=SpellE>src</span>/configure --with-<span
class=SpellE>apxs</span>=/path/to/apache/bin/<span class=SpellE>apxs</span>
<br>
<span class=SpellE>Mod_gzip</span>安装:<br>
/path/to/apache/bin/<span class=SpellE>apxs</span> -<span class=SpellE>i</span>
-a -c <span class=SpellE>mod_gzip.c</span><br>
工具:<span class=SpellE>cronolog</span>安装:<a href="http://www.cronolog.org"
target="_blank">http://www.cronolog.org</a> <br>
升级/维护:看看通用和模块化的安装过程如何简化了日常的升级/维护工作;<br>
按照以上的方法:系统管理员和应用管理员的职责可以清楚的分开,互相独立。<br>
系统安装:系统管理员的职责就是安装系统=>安装好一台DSO模式的APACHE,然后COLON,<br>
应用安装:由应用管理员负责具体应用所需要的模块并设置HTTPD。<br>
系统升级:系统管理员:升级系统/升级APACHE<br>
应用升级:系统管理员:升级应用模块 <br>
具体的说明:<br>
<br>
WEB应用的容量规划<br>
<br>
APACHE主要是一个内存消耗型的服务应用,我个人总结的经验公式:<br>
<span class=SpellE>apache_max_processerials_with_good_perfermance</span>
< (<span class=SpellE>total_hardware_memory</span> / <span class=SpellE>apache_memory_per_process</span>
) * 2<br>
<span class=SpellE>apache_max_process</span> = <span class=SpellE>apache_max_processerials_with_good_perfermance</span>
* 1.5<br>
<br>
为什么会有一个<span class=SpellE>apache_max_processerials_with_good_perfermance</span>和<span
class=SpellE>apache_max_process</span>呢?原因是在低负载下系统可以使用更多的内存用于文件系统的缓存,从而进一步提高单个请求的响应速度。在高负载下,系统的单个请求响应速度会<span
class=GramE>慢不少</span>,而超过<span class=SpellE>apache_max_process</span>,系统会因为开始使用硬盘做虚拟内存交换空间而导致系统崩溃。此外,同样的服务:2G内存的机器的<span
class=SpellE>apache_max_process</span>一般只设置到1G内存的1.7倍,因为APACHE本身会因为管理更多的进程而产生性能下降。<br>
<br>
例子1:<br>
一个apache + <span class=SpellE>mod_php</span>的服务器:一个apache进程一般需要4M内存<br>
因此在一个1G内存的机器上:<span class=SpellE>apache_max_processerials_with_good_perfermance</span>
< (1g / 4m) * 2 = 500<br>
<span class=SpellE>apache_max_process</span> = 500 * 1.5 = 750<br>
所以规划你的应用让服务尽量跑在500个APACHE以下,并设置APACHE的软上限在800个。<br>
<br>
例子2:<br>
一个apache + <span class=SpellE>mod_resin</span>的服务器: 一个apache进程一般需要2M内存<br>
在一个2G内存的机器上: <span class=SpellE>apache_max_processerials_with_good_perfermance</span>
< (2g / 2m ) * 2 = 2000<br>
因此:<span class=SpellE>apache_max_process</span> = 2000 * 1.5 = 3000<br>
<br>
以上估算都是按<span class=GramE>小文件</span>服务估算的(一个请求一般大小在20k以下)。对于文件下载类型站点,可能还会受其他因素:比如带宽等的影响。<br>
<br>
APACHE安装过程<br>
<br>
服务器个数的硬上限HARD_SERVER_LIMIT的修改:<br>
在FREEBSD和LINUX等UNIX操作系统下APACHE缺省的最大进程数是256个,需要修改apache_1.3.xx/src/include/httpd.h<br>
#<span class=SpellE>ifndef</span> HARD_SERVER_LIMIT<br>
#<span class=SpellE>ifdef</span> WIN32<br>
#define HARD_SERVER_LIMIT 1024<br>
#<span class=SpellE>elif</span> defined(NETWARE)<br>
#define HARD_SERVER_LIMIT 2048<br>
#else<br>
#define HARD_SERVER_LIMIT 2560 <===将原来的HARD_SERVER_LIMIT 256 后面加个“0”<br>
#<span class=SpellE>endif</span><br>
#<span class=SpellE>endif</span><br>
<br>
解释:<br>
APACHE缺省的最大用户数是256个:这个配置对于服务器内存还是256M左右的时代是一个非常好的缺省设置,但随着内存成本的急剧下降,现在大型站点的服务器内存配置一般比当时要高一个数量级不止。所以256个进程的硬限制对于一台1G内存的机器来说是太浪费了,而且APACHE的软上限<span
class=SpellE>max_client</span>是受限于HARD_SERVER_LIMIT的,因此如果WEB服务器内存大于256M,都应该调高APACHE的HARD_SERVER_LIMIT。根据个人的经验:2560已经可以满足大部分小于2G内存的服务器的容量规划了(APACHE的软上限的规划请看后面)。<br>
<br>
APACHE的编译:通用的编译选项能使安装过程标准化<br>
./configure --prefix=/<span class=SpellE>another_driver</span>/apache/
--enable-shared=max --enable-module=most<br>
<br>
解释:<br>
--prefix=/<span class=SpellE>another_driver</span>/apache/: 一个系统使用寿命最低的一般就是硬盘,因此:将服务数据和系统完全分开,不仅能提高了数据的访问速度,更重要的,大大方便系统升级,备份和恢复。<br>
<br>
--shared-module=max:使用动态加载方式会带来5%的性能下降,但和带来的好处<span class=GramE>相比更本不算</span>什么:比如模块升级方便,系统升级风险降低,安装过程标准化<br>
<br>
--enable-module=most:用most可以将一些不常用的module编译进来,比如后面讲到的<span class=SpellE>mod_expire</span>是就不在apache的缺省常用模块中<br>
<br>
如果不想build so, 也可以这样:<br>
./configure \<br>
"--with-layout=Apache" \<br>
"--prefix=/path/to/apache" \<br>
"--disable-module=access" \<br>
"--disable-module=actions" \<br>
"--disable-module=<span class=SpellE>autoindex</span>" \<br>
"--disable-module=<span class=SpellE>env</span>" \<br>
"--disable-module=<span class=SpellE>imap</span>" \<br>
"--disable-module=negotiation" \<br>
"--disable-module=<span class=SpellE>setenvif</span>" \<br>
"--disable-module=status" \<br>
"--disable-module=<span class=SpellE>userdir</span>" \<br>
"--disable-module=<span class=SpellE>cgi</span>" \<br>
"--disable-module=include" \<br>
"--disable-module=auth" \<br>
"--disable-module=<span class=SpellE>asis</span>"<br>
<br>
但结果会发现,这样编译对服务性能只能有微小的提高(5%左右),但却失去了以后系统升级和模块升级的灵活性,无论是模块还是APACHE本身升级都必须把所有SOURCE加在一起重新编译。<br>
<br>
apache的缺省配置文件一般比较大:我们可以使用去掉注释的方法精简一下:然后再进入具体的培植过程能让你更快的定制出你所需要的。<br>
<span class=SpellE>grep</span> -v "#" <span class=SpellE>httpd.conf.default</span>
><span class=SpellE>httpd.conf</span><br>
<br>
需要修改的通用项目有以下几个:<br>
<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -