📄 1315.html
字号:
</td>
</tr>
<tr>
<td noWrap>
<div align="center">
<input maxlength=100 size=30 name=keyword2>
</div>
</td>
</tr></tbody>
</table>
</form>
</TD>
<TD rowSpan=2><IMG src="images/header_r1_c7.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c7.gif" width=26 border=0 name=header_r1_c7></TD>
<TD><IMG height=83 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 border=0></TD></TR>
<TR>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"><IMG height=22
src="images/header_r2_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r2_c1.gif" width=296 border=0
name=header_r2_c1></TD>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colSpan=5>
<DIV align=right><FONT class=normalfont>当前位置:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<A href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</A> | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
</TD>
<TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff
border=0>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TR>
<TD vAlign=top align=middle width="60%">
<TABLE cellSpacing=0 cellPadding=0 width="100%"
background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
<TBODY>
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>LAMP架构服务器性能优化建议</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:高春辉<br>来自:Linux知识宝库<br>联系方式:无名<br><br>LAMP 架构服务器性能优化建议<br>
(03/11/2004,R1版)<br>
<br>
出处:http://www.paulgao.com.cn,欢迎转载。<br>
<br>
维护“手机之家”(http://www.imobile.com.cn)的服务器有快两年了,也有些经验心得,写在这里给大家分享。<br>
<br>
服务器配置如下:redhat linux 9.0、apache 1.3.29、php 4.3.4、mysql 3.23.58,以下建议均在以上平台上跑的很好,当然也跟你的应用有关系,具体实施要根据实际效果来进行。<br>
<br>
1、众所周知的方法就是使用 Zend Optimizer(简称 ZO,最新版本为 2.5.1) 或者 Zend Performance Suite(简称 ZPS,其中包含 ZO,最新版本为 3.6.0)对 PHP 进行加速。相关软件可到张微波的主页来下载哦,地址为:http://www.5ilinux.com/blog/archives/000093.html。<br>
<br>
2、apache配置优化(httpd.conf)<br>
1)修改“Timeout”的值为 30-60,如果你得程序没有执行时间需要很长的话,可以修改到 10-15;<br>
2)修改“KeepAlive”的值为“Off”,这个很有效果,也很有争议,我自己的看法是很有效果,而且并没有影响速度,大家可以自行试验;<br>
3)修改“MaxRequestsPerChild”的值为“2048”,这个还在试验中,一是因为怕有内存泄漏,二是因为 apache 进程会因为随着服务时间的延长,会变得越来越胖(我这里的实际情况是某些 apache 进程会狂吃内存到18MB,晕啊:),不过这设置有没有效果,还在试验中;<br>
4)在不使用 .htaccess 的情况下,将其“<Files .htaccess>”部分设置为“None”方式,如果你使用 PHPMYADMIN 进行管理的话,可以使用 PHPMYADMIN 的 COOKIE 权限控制方式。<br>
<br>
3、卸载不必要的模块,不管是静态编译还是 DSO 模式,以便节省内存占用。具体模块可以参照 apache 的手册,这里就不多说了。PHP 也是同样,我基本上已经把不用的模块都卸载了:)<br>
<br>
4、使用 mod_gzip 进行加速,很简单,就不多说了。<br>
<br>
5、如果你的服务器还是负载很高的话,更极端的方式就是在 httpd.conf 里面将日志停掉了,不过一般要保留 errorlog 才好,以便排错,而且要记得,不是把“CustomLog”注释掉就行了,而要使用“CustomLog /dev/null common”这样的方式才好。<br>
<br>
6、如果你的 PHP 程序使用 Session 对话的话,可以在 php.ini 里面将“session.save_path”设置为“session.save_path = /dev/shm”,因为 /dev/shm 是 linux 系统独有的 TMPFS 文件系统,是以内存为主要存储方式的文件系统,比 RAMDISK 要好,因为可以使用 DISKSWAP 作为补充,而且是系统自带,不需要另行配置,想想吧,从磁盘IO操作到内存操作,速度会快多少?:)你也可以把你所需要的临时文件都写在 /dev/shm 下,只是别忘了,重启就没有啦,我是只存放目标文件的,呵呵。额外的说明资料请看“使用虚拟内存(virtual memory,VM)文件系统和绑定安装”(http://www-900.ibm.com/developer ... m/l-fs3/index.shtml)。<br>
<br>
7、MYSQL 的优化(/etc/my.cnf)<br>
1)确认在“[mysqld]”部分加入了“skip-innodb”和“skip-bdb”参数;<br>
2)确认在“[mysqld]”部分加入了“skip-name-resolve”和“skip-locking”参数;<br>
3)如果不需要的话,可以将二进制日志(binlog)停掉,方法是将“log-bin”注释掉;<br>
4)在内存允许的情况下,对一些参数进行重新配置,目标在于将大部分操作集中于内存中,尽量不进行磁盘操作,对于我的 MYSQL 服务器我是如下修改的,基于 2G 内存情况:<br>
<br>
[mysqld]<br>
set-variable = key_buffer=512M<br>
set-variable = max_allowed_packet=4M<br>
set-variable = table_cache=1024<br>
set-variable = thread_cache=64<br>
set-variable = join_buffer_size=32M<br>
set-variable = sort_buffer=32M<br>
set-variable = record_buffer=32M<br>
set-variable = max_connections=512<br>
set-variable = wait_timeout=120<br>
set-variable = interactive_timeout=120<br>
set-variable = max_connect_errors=30000<br>
set-variable = long_query_time=1<br>
set-variable = max_heap_table_size=256M<br>
set-variable = tmp_table_size=128M<br>
set-variable = thread_concurrency=8<br>
set-variable = myisam_sort_buffer_size=128M<br>
<br>
你可以根据“show status”命令返回的状态进行微调。我主要注意以下变量的数值,越小越好,最好为零:)<br>
Created_tmp_disk_tables<br>
Created_tmp_tables<br>
Created_tmp_files<br>
Slow_queries<br>
<br>
8、在启动脚本中使用“--log-slow-queries=/home/logs/mysql_slow.log”参数,以便进行 SQL 语句的优化工作,这个其实是很很重要的工作。记得一定要在 my.cnf 中设置“set-variable = long_query_time=1”才行。<br>
<br>
9、另外可以使用 4.0.xx 版本的 MYSQL,4.0.xx 版本除了一些性能提升以外,还有 QueryCache 方法,就是在 SQL 语句查询结果没有变动之前,将其结果进行缓存,下次再进行同样的 SQL 语句查询就可以直接反回结果,当然也是以牺牲内存为前提:)<br>
<br>
10、额外的,对于 LINUX EXT3 文件系统还有一个小技巧可用,就是在修改 /etc/fstab 中的参数,比如“/dev/sdb2 /home ext3 defaults 1 2”改为“/dev/sdb2 /home ext3 noatime 1 2”,“noatime”的意思就是不修改 accesstime,对于磁盘文件读写频繁的服务器也应该可以降低一些效果。不过最好不要远程操作,不然因为修改失误,服务器不能启动了,可别怪我:)<br>
<br>
好了,基本上我用过的方法已经说过一遍了,有些方法是取自于一些很好的文章,由于未作保留,所以无法写出出处,只能泛泛的表示感谢了。其中有些方法也适用于 Windows 平台,大家可以根据自己的服务器、应用情况去进行应用,大家也可一说说自己的办法,比如改用 ZEUS 来做 webserver,我也在找更多的办法来提升服务器性能,比如基于 LINUX KERNEL v2.4 以上内核的一些性能优化方法,从 network 到 swap(因为内核升级,所以一些老版本内核的方法已经不能再使用了:)。我也会进一步更新这篇文章,让大家能够更好的进行服务器的性能提升工作~<br>
<br>
另外欢迎来访问国内数一数二的手机网站,手机之家,地址见下,呵呵~<br>
<br>
高春辉<br>
mailto:paulgao@yeah.net<br>
手机之家网站(http://www.imobile.com.cn)
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -