<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Chen's blog]]></title> 
<link>http://blog.hackroad.com/index.php</link> 
<description><![CDATA[人生在世,吃喝二字!]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Chen's blog]]></copyright>
<item>
<link>http://blog.hackroad.com/read.php/505.htm</link>
<title><![CDATA[Windows下的Memcache安装]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Mon, 06 Feb 2012 02:02:25 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/505.htm</guid> 
<description>
<![CDATA[ 
	很多phper不知道如何在Windows下搭建Memcache的开发调试环境，最近个人也在研究Memcache，记录下自己安装搭建的过程。<br/>其实我开始研究Memcache的时候并不知道居然还有memcached for Win32这个鸟东西，害得我在CnetOS下折腾1天才搞定，今天突然发现Windows下的Memcache进行开发调试完全没有问题，所以写篇Memcache的文档分享给大家。<br/><br/>Windows下的Memcache安装：<br/>1. 下载memcache的windows稳定版，解压放某个盘下面，比如在c:&#92;memcached<br/>2. 在终端（也即cmd命令界面）下输入 'c:&#92;memcached&#92;memcached.exe -d install' 安装<br/>3. 再输入： 'c:&#92;memcached&#92;memcached.exe -d start' 启动。NOTE: 以后memcached将作为windows的一个服务每次开机时自动启动。这样服务器端已经安装完毕了。<br/>4.下载php_memcache.dll，请自己查找对应的php版本的文件<br/>5. 在C:&#92;winnt&#92;php.ini 加入一行 'extension=php_memcache.dll'<br/>6.重新启动Apache，然后查看一下phpinfo，如果有memcache，那么就说明安装成功！<br/><br/><br/>memcached的基本设置：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>-p 监听的端口 -l 连接的IP地址, 默认是本机 -d start 启动memcached服务 -d restart 重起memcached服务 -d stop&#124;shutdown 关闭正在运行的memcached服务 -d install 安装memcached服务 -d uninstall 卸载memcached服务 -u 以的身份运行 (仅在以root运行的时候有效) -m 最大内存使用，单位MB。默认64MB -M 内存耗尽时返回错误，而不是删除项 -c 最大同时连接数，默认是1024 -f 块大小增长因子，默认是1.25 -n 最小分配空间，key+value+flags默认是48 -h 显示帮助<br/></div></div><br/><br/><br/>Memcache环境测试：<br/>运行下面的php文件，如果有输出This is a test!，就表示环境搭建成功。开始领略Memcache的魅力把！<br/>< ?php<br/>$mem = new Memcache;<br/>$mem->connect("127.0.0.1", 11211);<br/>$mem->set('key', 'This is a test!', 0, 60);<br/>$val = $mem->get('key');<br/>echo $val;<br/>?><br/>
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/504.htm</link>
<title><![CDATA[Windows 7终端管理 ]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Fri, 03 Feb 2012 08:27:22 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/504.htm</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;个人感觉很好用推荐给大家用,特别是IT工作者,平时做事很多地方用到远程桌面,可以提高效率.&nbsp;&nbsp;&nbsp;&nbsp; <br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 经常使用远程桌面管理众多服务器的朋友们可能都使用过Windows MMC中的“远程桌面”功能，使用它可以很容易的保存N多远程桌面连接，而不用每次需要连接某台服务器时重复的Alt+R、mstsc。Windows工作站操作系统MMC中默认是没有“远程桌面”这个功能模块的，需手动添加，WinXp可以安装Srv2003的管理包或手动复制2003 system32下的mstsmmc.dll 和 mstsmhst.dll 并注册后即可在MMC中添加并使用该功能。<br/>而Win7照搬Xp下的操作办法显然不可行，好在微软给出了解决方案，搜了半天才找到。<br/>1.去MS中国下载“Windows 7 远程服务器管理工具”，KB958850，200多M，<br/>下载地址 <br/><a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7d2f6ad7-656b-4313-a005-4e344e43997d" target="_blank">http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7d2f6ad7-656b-4313-a005-4e344e43997d</a><br/>2.安装完成后依次打开“控制面板”-“程序和功能”-“打开或关闭Windows功能”-“远程服务器管理工具”-“角色管理工具”，勾选下面的“远程桌面服务工具。<br/><br/>3.此时重新打开MMC控制台，添加管理单元时就可以选择并添加“远程桌面”管理单元了。
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/503.htm</link>
<title><![CDATA[FAN: nagios 自动化]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Windows]]></category>
<pubDate>Mon, 30 Jan 2012 06:12:02 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/503.htm</guid> 
<description>
<![CDATA[ 
	FAN是 “Fully Automated Nagios” 的缩写。FAN的包含了由nagios社区提供的所有nagios工具包，同时FAN提供iso镜像，使得nagios安装非常容易。<br/>FAN是基于centos 系统之上的。<br/><br/>AN是基于centos 系统之上的。<br/>FAN包含以下工具:<br/>Nagios: Core monitoring application（核心监视应用）<br/>Nagios plugins: plugins to monitor servers （监视服务的插件）<br/>Centreon: web frontend for Nagios (Centreon is one of the better tools for that!)（更好的网页界面展示工具）<br/>NagVis: a great tools for configuring maps （不错的图形配置工具）<br/>NDOUtils: Nagios module to store monitoring data in MySQL （将数据存入mysql的Nagios 模块）<br/>NRPE: the check_nrpe plugin (NRPE daemon is not provided) （check_nrpe 插件）<br/>NaReTo (Nagios Reporting Tools): a great tool for getting availabilty report（状态报告配置工具）<br/><br/><a href="http://fannagioscd.sourceforge.net/wordpress/wp-content/uploads/2011/02/screen_centreon2.png" class="highslide" onclick="return hs.expand(this)"><img src="http://fannagioscd.sourceforge.net/wordpress/wp-content/uploads/2011/02/screen_centreon2.png" class="insertimage" alt="Highslide JS" title="点击图片放大" border="0" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>下载地址<br/><br/><a href="http://fannagioscd.sourceforge.net/wordpress/download/" target="_blank">http://fannagioscd.sourceforge.net/wordpress/download/</a><br/>
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/502.htm</link>
<title><![CDATA[在Linux（CentOS）安装MRTG的教程]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Thu, 19 Jan 2012 08:56:01 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/502.htm</guid> 
<description>
<![CDATA[ 
	一、MRTG需要以SNMP服务为基础，所以请确保你的系统已经启用了此服务(关于SNMP协议请参考：SNMP简介和MRTG监控过程)<br/><br/>1.请确保你的系统安装了以下软件包<br/>net-snmp-5.0.6-17<br/>net-snmp-devel-5.0.6-17<br/>net-snmp-utils-5.0.6-17<br/>使用YUM –y install net-snmp<br/>Yum –y install net-snmp-devel<br/>Yum –y install net-snmp-utils<br/><br/>2.修改/etc/snmp/snmpd.conf<br/><br/>去掉如下一行的注释<br/>view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc<br/><br/>在大约55行处添加如下一行<br/>view systemview included .1.3.6.1.2.1.2<br/><br/>把如下行<br/>access notConfigGroup "" any noauth exact systemview none none<br/>改作：<br/>access notConfigGroup "" any noauth exact mib2 none none<br/><br/>3.启用snmpd服务<br/>#service snmpd start<br/>#chkconfig --levle 2345 snmpd on<br/><br/>4.查看端口的开启状况<br/># netstat -tunlp &#124;grep snmp<br/>tcp 0 0 0.0.0.0:199 0.0.0.0:* LISTEN 4973/snmpd<br/>udp 0 0 0.0.0.0:161 0.0.0.0:* 4973/snmpd<br/><br/>二、MRTG生成供浏览图像需要httpd服务的支持，同时也需要gd、libpng和zlib三个软件包的支持，而gd的正常运行也需要其它的几个软件，下面一并安装它们<br/><br/>1.安装zlib-1.2.3<br/>#tar zxvf zlib-1.2.3.tar.gz<br/>#cd zlib-1.2.3<br/>#./configure --prefix=/usr/local/zlib<br/>#make<br/>#make install<br/><br/>2.安装httpd-2.2.4<br/>#tar zxvf httpd-2.2.4.tar.gz<br/>#cd httpd-2.2.4<br/>#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-track-vars --enable-rewrite --with-z-dir=/usr/local/zlib<br/>#make<br/>#make install<br/>启动httpd<br/>/usr/local/apache/bin/apachectl -k start<br/><br/>3.安装libpng-1.2.14<br/>#tar zxvf libpng-1.2.14.tar.gz<br/># cd libpng-1.2.14<br/># cp scripts/makefile.linux makefile<br/># make （若是提示找不到zlib库文件或者头文件，多半是makefile文件里zlib的默认路径有误。可编辑makefile文件，找到zlib项并重新指定路径到/usr/local/zlib/lib和/usr/local/zlib/include）。<br/>Vi makefile<br/>Zliblib=/usr/local/zlib/lib<br/>Zlibinc=/usr/local/zlib/include 去掉开头的“#”<br/># make install<br/><br/>4.安装freetype-2.1.10<br/># tar -zvxf freetype-2.1.10.tar.gz<br/># cd freetype-2.1.10<br/># mkdir -p /usr/local/freetype<br/># ./configure --prefix=/usr/local/freetype<br/># make;make install<br/><br/>5.安装jpegsrc.v6b<br/>jpeg默认不会自建目录，因此需手动建立目录：<br/># mkdir -pv /usr/local/jpeg6/&#123;,bin,lib,include,man/&#123;,man1&#125;,man1&#125;<br/>安装<br/>#tar zxvf jpegsrc.v6b.tar.gz<br/># ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static<br/># make<br/># make install<br/># make install-lib<br/><br/>6.安装libxml2-2.6.19<br/># tar -zxf libxml2-2.6.19.tar.gz<br/># cd libxml2-2.6.19<br/># mkdir -p /usr/local/libxml2<br/># ./configure --prefix=/usr/local/libxml2<br/># make; make install<br/>#cp xml2-config /usr/bin<br/><br/>7.安装GD-2.0.33库<br/># tar -zvxf gd-2.0.33.tar.gz<br/># mkdir -p /usr/local/gd2<br/># cd gd-2.0.33<br/># ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/zlib/ --with-freetype=/usr/local/freetype/<br/># make<br/># make install<br/><br/>三、安装配置MRTG<br/><br/>1.下载mrtg,目前最新版本为mrtg-2.15.1<br/><a href="http://oss.oetiker.ch/mrtg/pub/mrtg-2.15.1.tar.gz" target="_blank">http://oss.oetiker.ch/mrtg/pub/mrtg-2.15.1.tar.gz</a><br/><br/>2.安装mrtg-2.15.1<br/>#tar zxvf mrtg-2.15.1.tar.gz<br/># cd mrtg-2.15.1<br/># ./configure --prefix=/usr/local/mrtg --sysconfdir=/etc/mrtg --with-gd=/usr/local/gd2/include --with-gd-lib=/usr/local/gd2/lib --with-gd-inc=/usr/local/gd2/include --with-png=/usr/local/include --with-png-lib=/usr/local/lib --with-png-inc=/usr/local/include --with-zlib=/usr/local/zlib/include --with-zlib-lib=/usr/local/zlib/include --with-zlib-inc=/usr/local/zlib/include<br/># make<br/># make install<br/><br/>3.基本配置<br/><br/>生成主配置文件<br/>Mkdir /etc/mrtg<br/>touch /etc/mrtg/mrtg.cfg<br/>#/usr/local/mrtg/cfgmaker public@localhost > /etc/mrtg/mrtg.cfg<br/><br/>编辑/etc/mrtg/mrtg.cfg<br/>将<br/>#WorkDir:/home/http/mrtg<br/>去掉注释并改为<br/>WorkDir: /usr/local/apache/htdocs/mrtg (此处是你的httpd默认的主目录)<br/><br/>去掉如下行的注释<br/>#Options[_]: growright, bits<br/><br/>添加如下行，实现网页中的中文字符显示<br/>Language:gb2312<br/><br/>生成MRTG网页主页面文件<br/>#/usr/local/mrtg/bin/indexmaker /etc/mrtg/mrtg.cfg --output=/usr/local/apache/htdocs/mrtg/index.html --title="My MRTG"<br/><br/>4.启动MRTG<br/>#env LANG=C /usr/local/mrtg/bin/mrtg /etc/mrtg/mrtg.cfg<br/>这个命令会输出一些错误信息，一般可以安全忽略，连续执行三次此命令即可。<br/><br/>5.MRTG生成的web页面是静态的，为了能让其不断的刷新，需要将以上命令添加进crontab<br/>#crontab -e<br/>添加如下一行<br/>*/3 * * * * env LANG=C /usr/local/mrtg/bin/mrtg /etc/mrtg/mrtg.cfg<br/>注：此行表示每三分钟刷新一次，你可以根据自己的需要修改刷新时间间隔。<br/><br/>6.安装完毕，可以去查看结果了,在浏览器输入形如以下地址<br/><a href="http://192.168.1.6/mrtg" target="_blank">http://192.168.1.6/mrtg</a> (IP地址为你的机器IP)<br/><br/>四、一个示例：内存使用监视<br/><br/>1.新建一个存放脚本的文件夹<br/>#mkdir -pv /usr/local/apache/htdocs/mrtgsh<br/><br/>2.建立脚本文件<br/>#vi /usr/local/apache/htdocs/mrtgsh/mrtg.memory<br/>添加如下脚本：<br/>#!/bin/bash<br/># run this script to check the mem usage.<br/>totalmem=`/usr/bin/free &#124;grep Mem &#124;awk '&#123;print $2&#125;'`<br/>usedmem=`/usr/bin/free &#124;grep Mem &#124;awk '&#123;print $3&#125;'`<br/>UPtime=`/usr/bin/uptime &#124; awk '&#123;print $3""$4""$5&#125;'`<br/>echo $totalmem<br/>echo $usedmem<br/>echo $UPtime<br/>让其具有运行权限<br/>#chmod 755 /usr/local/apache/htdocs/mrtgsh/mrtg.memory<br/><br/>3.编辑/etc/mrtg/mrtg.cfg<br/>添加如下内容<br/>Target[memory]: `/usr/local/apache/htdocs/mrtgsh/mrtg.memory`<br/>MaxBytes[memory]: 4096000<br/>Title[memory]:Memory Usages<br/>ShortLegend[memory]: &<br/>kmg[memory]:kB,MB<br/>kilo[memory]:1024<br/>YLegend[memory]: Memory Usage :<br/>Legend1[memory]: Total Memory :<br/>Legend2[memory]: Used Memory :<br/>LegendI[memory]: Total Memory :<br/>LegendO[memory]: Used Memory :<br/>Options[memory]: growright,gauge,nopercent<br/>PageTop[memory]:<br/>Memory Usages<br/><br/>4.重新生成主页面文件<br/>#/usr/local/mrtg/bin/indexmaker /etc/mrtg/mrtg.cfg --output=/usr/local/apache/htdocs/mrtg/index.html --title="My MRTG"<br/><br/>5.可根据情况重新启动MRTG，然后就可以查看效果了。
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/501.htm</link>
<title><![CDATA[在Centos(RHEL)上安装和配置MRTG]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Thu, 19 Jan 2012 08:15:42 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/501.htm</guid> 
<description>
<![CDATA[ 
	MRTG是个很过时的东西.现在大多都用RRD,但配置有点麻烦,当然,用Cacti之类还是相当方便.但我在这使用MRTG原因有三.<br/>1.我只有一台机器要用,比如我的个人网站.为了一个小服务器搞个cacti不值.象这样MRTG还是很方便的.<br/>2.就算大面积使用Cacti加RRD还是有必要在本机运行一个可以直接查看的网页比较方便.方便运维排错.<br/>3.可以在一个节点的一台机器上装一个MRTG,然后加上那个节点后面所有的机器,这样可以显示每个节点的流量,方便节点排错.<br/> <br/> <br/>MRTG的全称叫 Multi Router Traffic Grapher 可以监控很多东西,今天我们就用它来监控我小小的个人网站的流量.节点之类多设备的设置后面也可以参考一下.<br/> <br/>第一步: 安装 MRTG 和snmp<br/><br/>yum install mrtg net-snmp net-snmp-utils<br/> <br/>第二步：配置 snmpd<br/>我不建议使用自己来配置这个配置文件.直接使用 snmpconf 这个软件就可以很好的<br/><br/>vi /etc/snmp/snmpd.conf<br/> 修改成下面这样主要是com2sec那行的可以snmp来打开的地址和密码根据你的需要来设置一下.还有就是access部分后面的权限,可以设置成all之类.<br/><br/>com2sec notConfigUser&nbsp;&nbsp;localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public<br/> <br/>group&nbsp;&nbsp; notConfigGroup v1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notConfigUser<br/>group&nbsp;&nbsp; notConfigGroup v2c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notConfigUser<br/> <br/>view&nbsp;&nbsp;&nbsp;&nbsp;systemview&nbsp;&nbsp;&nbsp;&nbsp;included&nbsp;&nbsp; .1.3.6.1.2.1.1<br/>view&nbsp;&nbsp;&nbsp;&nbsp;systemview&nbsp;&nbsp;&nbsp;&nbsp;included&nbsp;&nbsp; .1.3.6.1.2.1.25.1.1<br/> <br/>access&nbsp;&nbsp;notConfigGroup ""&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;any&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; noauth&nbsp;&nbsp;&nbsp;&nbsp;exact all none none<br/>view all&nbsp;&nbsp;&nbsp;&nbsp;included&nbsp;&nbsp;.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 80<br/> <br/>syslocation Unknown (edit /etc/snmp/snmpd.conf)<br/>syscontact Root <br/>注：<br/>com2sec notConfigUser&nbsp;&nbsp;localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public 这个后面二个选项是指,可以取得信息的地址为 Localhost,使用的验证码为 public<br/>access&nbsp;&nbsp;notConfigGroup ""&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;any&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; noauth&nbsp;&nbsp;&nbsp;&nbsp;exact all none none 这行中,会打开读信息.可以读取所有的信息,倒数第三个选项 all 来指定.<br/><br/>记的重起服务<br/><br/><br/>service snmpd restart<br/> <br/>我们来确认一下我们的配置,用下面的命令,看看能不能得到你接口的ip信息<br/><br/>snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex<br/> <br/>我的输出如下:<br/> <br/>IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1<br/>IP-MIB::ipAdEntIfIndex.221.9.252.35 = INTEGER: 2<br/> <br/> <br/>第三步:配置MRTG<br/> <br/>我们使用cfgmaker的命令来建立 /etc/mrtg.cfg 文件,输入如下命令:<br/>1<br/>cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg.cfg public@localhost<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;* –global 'WorkDir: /var/www/mrtg' : 设置全局的工作目录配置,也就是存MRTG的图象的地址<br/>&nbsp;&nbsp;&nbsp;&nbsp;* –global "Options[_]: growright,bits" :设置网络显示<br/>&nbsp;&nbsp;&nbsp;&nbsp;* –output /etc/mrtg.cfg: 你输出的配置文件的地址<br/>&nbsp;&nbsp;&nbsp;&nbsp;* public@localhost : public是你的snmp设备读的密码,localhost是设备的密码.如果你要显示远程的snmp的设备,就是远程的地址的密码,现在我这是本地的.<br/> <br/>设置完后,运行indexmaker来建立网页显示接口的信息.这个只需运行一次,你加入新的设备和新监控内容才需要更新.<br/><br/>indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg<br/> <br/>第四步:加入定时任务<br/> <br/>http服务都会配置吧,这个就不教了哦…crontab我想都会加吧.加入下面的命令到crontab中吧<br/><br/>*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok<br/> <br/>最后你打开你的网站的<br/><a href="http://your-ip.add.ress/mrtg/" target="_blank">http://your-ip.add.ress/mrtg/</a><br/><br/>比如我的网站就是:<a href="http://www.php-oa.com/mrtg/" target="_blank">http://www.php-oa.com/mrtg/</a><br/> <br/> <br/>FQA:<br/>1.怎么加入多个节点内其它的多个设备<br/>本地运行下面的命令<br/><br/>cfgmaker --global 'WorkDir: /var/www/mrtg' &#92;<br/>--output /etc/mrtg/mrtg.cfg &#92;<br/>--global "Options[_]: growright,bits" &#92;<br/>--ifref=nr &#92;<br/>public@192.168.0.1 &#92;<br/>public@192.168.0.2 &#92;<br/>public@192.168.0.3 &#92;<br/>远程主机<br/>只需要配置snmp的配置,配置如上面提到的一样,只是配置中的可以读snmp的localhost需要修改成显示的那个地址.<br/>2.怎么显示成中文<br/>在你的/etc/mrtg.conf配置之间加入<br/>Language: Chinese&nbsp;&nbsp;&nbsp;&nbsp; #注意：不要用Language: gb2312,因为用Language: gb2312会出现流量单位b不能正常显示的问题<br/>3.怎么显示指定接口的流量<br/>在cfgmaker命令参数后面加入接口信息 –ifref=ip<br/>ifref可以指定为nr、ip、eth、descr、name.nr表示用接口在MIBII库中Interface接口的ifIndex来识别接口.<br/><br/>cfgmaker --global 'WorkDir: /var/www/mrtg'&nbsp;&nbsp; --ifref=ip&nbsp;&nbsp;--output /etc/mrtg.cfg public@localhost<br/> <br/> <br/>附:1: mrtg.cfg 里面几个参数的意思. <br/>Target：是要执行的脚本 <br/>Xsize：生成图表的横向宽度（最大600） <br/>Ysize：生成图表的纵向高度（最大200） <br/>Title：标题 <br/>kMG: Change the default multiplier prefixes <br/>Ytics：纵向划分为几个块（格子） <br/>MaxBytes：图表纵向数值的最大上限 <br/>PageTop：页面上面的提示 <br/>kilo：一般是写1024,如果需要的话,是1000在计算机里的单位 <br/>LegendI：从SHELL返回的数据中的第一个 <br/>LegendO：从SHELL返回的数据中的第二个 <br/>Options： growright,表示图表向右延展 
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/500.htm</link>
<title><![CDATA[Nginx访问控制]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Wed, 18 Jan 2012 09:45:39 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/500.htm</guid> 
<description>
<![CDATA[ 
	一般网站的后台都不能给外部访问，所以要添加IP限制，通常只允许公司的IP访问<br/>限制整个域名访问就要server下添加：<br/>server &#123;<br/>listion 80;<br/>server_name lihuipeng.blog.51cto.com;<br/>root /opt/htdocs/www;<br/><br/>allow&nbsp;&nbsp; 100.100.100.100;<br/>deny&nbsp;&nbsp;&nbsp;&nbsp;all;<br/><br/>还可以做到PHP的解释限制：<br/> location ~ .*&#92;.php?$<br/>&#123;<br/>allow&nbsp;&nbsp; 100.100.100.100;<br/>deny&nbsp;&nbsp;&nbsp;&nbsp;all;<br/>fastcgi_pass&nbsp;&nbsp;127.0.0.1:9000;<br/>fastcgi_index index.php;<br/>include fcgi.conf;<br/>&#125;<br/><br/>除了限制IP之然还可以给域名添加帐号码密验证：<br/> server &#123;<br/>listion 80;<br/>server_name lihuipeng.blog.51cto.com;<br/>root /opt/htdocs/www;<br/><br/>allow&nbsp;&nbsp; 100.100.100.100;<br/>deny&nbsp;&nbsp;&nbsp;&nbsp;all;<br/>auth_basic “lihuipeng website”;<br/>auth_basic_user_file htpasswd;<br/><br/>location ~ .*&#92;.php?$<br/>&#123;<br/>….<br/>&#125;<br/><br/>htpasswd 这个密码很眼熟吧，就是用apache生成的，也有在线生成htpasswd的！
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/499.htm</link>
<title><![CDATA[Nginx限制带宽]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Wed, 18 Jan 2012 09:43:15 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/499.htm</guid> 
<description>
<![CDATA[ 
	用Nginx做下载服务的时候，可能会做下载速度限制，这个Nginx可以做到：<br/>首先在http&#123;&#125;的配置中添加一条：<br/>limit_zone one $binary_remote_addr 10m;然后在server&#123;&#125;的配置中添加：<br/>location / &#123;<br/>&nbsp;&nbsp;limit_conn one 1;&nbsp;&nbsp;限制线程<br/>&nbsp;&nbsp;limit_rate 100k;&nbsp;&nbsp;&nbsp;&nbsp; 限制速度<br/>&#125;<br/>表示限速100K每个客户端只允许一个线程<br/><br/>客户端最终速度=rate * conn，这样就可以完美的实现限制带宽的设置了。
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/498.htm</link>
<title><![CDATA[nginx 禁止以ip形式访问服务器]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Wed, 18 Jan 2012 09:41:03 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/498.htm</guid> 
<description>
<![CDATA[ 
	在nginx.conf中加入：<br/><br/><div class="code"><br/>&nbsp;&nbsp;server &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen 80;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name _;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 404;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; <br/></div><br/><br/>加在所有server的前面！<br/>然后重启服务！
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/497.htm</link>
<title><![CDATA[Nginx+mysql+php-fpm搭建高性能Nginx平台]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Wed, 18 Jan 2012 09:33:49 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/497.htm</guid> 
<description>
<![CDATA[ 
	系统环境：rhel4.7、centos5.5<br/>1、马上看看所需软件<br/>mysql-5.0.92.tar.gz <br/>libiconv-1.13.tar.gz<br/>libxml2-2.6.31.tar.gz<br/>jpegsrc.v6b.tar.gz<br/>freetype-2.3.5.tar.gz<br/>zlib-1.2.3.tar.gz<br/>libpng-1.2.40.tar.gz<br/>gd-2.0.35.tar.gz<br/>libmcrypt-2.5.7.tar.gz<br/>php-5.2.17.tar.gz<br/>php-5.2.17-fpm-0.5.14.diff.gz<br/>pcre-8.01.tar.gz<br/>nginx-0.9.5.tar.gz<br/>memcache-2.2.5.tgz<br/>eaccelerator-0.9.5.3.tar.bz2<br/>呼拉拉，一大堆软件，马上看看怎么安装这一大堆软件！<br/><br/>2、安装mysql<br/> tar xvfz mysql-5.0.92.tar.gz<br/>cd mysql-5.0.92<br/>./configure --prefix=/usr/local/mysql --localstatedir=/home/var --with-charset=utf8 --with-extra-charsets=all --with-berkeley-db --with-innodb --without-readline --enable-assembler --with-pthread --enable-thread-safe-client --with-client-ldflags=-all-static<br/>make<br/>make install<br/>如何不打算在本机器上运行mysql，可以跳过下面这一步<br/>配置mysql<br/> <br/>vi /etc/my.cnf<br/>[client]<br/>character-set-server = utf8<br/>port&nbsp;&nbsp;&nbsp;&nbsp;= 3306<br/>socket&nbsp;&nbsp;= /tmp/mysql.sock<br/><br/>[mysqld]<br/>character-set-server = utf8<br/>replicate-ignore-db = mysql<br/>replicate-ignore-db = test<br/>replicate-ignore-db = information_schema<br/>user&nbsp;&nbsp;&nbsp;&nbsp;= mysql<br/>port&nbsp;&nbsp;&nbsp;&nbsp;= 3306<br/>socket&nbsp;&nbsp;= /tmp/mysql.sock<br/>basedir = /usr/local/webserver/mysql<br/>datadir = /home/var<br/>log-error =&nbsp;&nbsp;/home/var/mysql_error.log<br/>pid-file =/home/var/mysql.pid<br/>open_files_limit&nbsp;&nbsp;&nbsp;&nbsp;= 10240<br/>back_log = 600<br/>max_connections = 5000<br/>max_connect_errors = 6000<br/>table_cache = 614<br/>external-locking = FALSE<br/>max_allowed_packet = 32M<br/>sort_buffer_size = 1M<br/>join_buffer_size = 1M<br/>thread_cache_size = 300<br/>#thread_concurrency = 8<br/>query_cache_size = 512M<br/>query_cache_limit = 2M<br/>query_cache_min_res_unit = 2k<br/>default-storage-engine = MyISAM<br/>thread_stack = 192K<br/>transaction_isolation = READ-COMMITTED<br/>tmp_table_size = 246M<br/>max_heap_table_size = 246M<br/>long_query_time = 3<br/>log-slave-updates<br/>log-bin = /home/var//binlog/binlog<br/>binlog_cache_size = 4M<br/>binlog_format = MIXED<br/>max_binlog_cache_size = 8M<br/>max_binlog_size = 1G<br/>relay-log-index = /home/var/relaylog/relaylog<br/>relay-log-info-file = /home/var/relaylog/relaylog<br/>relay-log = /home/var/relaylog/relaylog<br/>expire_logs_days = 30<br/>key_buffer_size = 256M<br/>read_buffer_size = 1M<br/>read_rnd_buffer_size = 16M<br/>bulk_insert_buffer_size = 64M<br/>myisam_sort_buffer_size = 128M<br/>myisam_max_sort_file_size = 10G<br/>myisam_repair_threads = 1<br/>myisam_recover<br/><br/>interactive_timeout = 120<br/>wait_timeout = 120<br/><br/>skip-name-resolve<br/>#master-connect-retry = 10<br/>slave-skip-errors = 1032,1062,126,1114,1146,1048,1396<br/><br/>#master-host&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp; 192.168.1.2<br/>#master-user&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp; username<br/>#master-password =&nbsp;&nbsp; password<br/>#master-port&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;3306<br/><br/>server-id = 1<br/><br/>innodb_additional_mem_pool_size = 16M<br/>innodb_buffer_pool_size = 512M<br/>innodb_data_file_path = ibdata1:256M:autoextend<br/>innodb_file_io_threads = 4<br/>innodb_thread_concurrency = 8<br/>innodb_flush_log_at_trx_commit = 2<br/>innodb_log_buffer_size = 16M<br/>innodb_log_file_size = 128M<br/>innodb_log_files_in_group = 3<br/>innodb_max_dirty_pages_pct = 90<br/>innodb_lock_wait_timeout = 120<br/>innodb_file_per_table = 0<br/><br/>#log-slow-queries = /home/var/slow.log<br/>#long_query_time = 10<br/><br/>[mysqldump]<br/>quick<br/>max_allowed_packet = 32M<br/> <br/>初始化数据库及配置启动方法<br/>/usr/local/mysql/bin/mysql_install_db --user=mysql<br/>chown -R mysql:mysql /home/var<br/>/usr/local/mysql/bin/mysqld_safe --user=mysql &<br/>cp ./support-files/mysql.server /etc/rc.d/init.d/mysql&nbsp;&nbsp;&nbsp;&nbsp; mysql.server在安装目录下<br/>chmod +x /etc/rc.d/init.d/mysql<br/>chkconfig --add mysql<br/>service mysql start<br/>/usr/local/mysql/bin/mysqladmin -u root password 57DwNRI3pirdSAP<br/>cd /usr/bin<br/>ln -s /usr/local/mysql/bin/mysql mysql<br/>3、安装libiconv、libxml2、gd等PHP库<br/> tar zxvf libiconv-1.13.tar.gz<br/>cd libiconv-1.13/<br/>./configure --prefix=/usr/local/libiconv/<br/>make<br/>make install<br/>cd ..<br/>tar zxvf libxml2-2.6.31.tar.gz<br/>cd libxml2-2.6.31<br/>./configure --prefix=/usr/local/libxml2<br/>make<br/>make install<br/>cd ..<br/>mkdir -pv /usr/local/jpeg6/&#123;,bin,lib,include,man/man1,man1&#125;<br/>tar vzxf jpegsrc.v6b.tar.gz<br/>cd jpeg-6b<br/>./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static<br/>make<br/>make install<br/>cd ..<br/>tar zvxf freetype-2.3.5.tar.gz <br/>cd freetype-2.3.5<br/>./configure --prefix=/usr/local/freetype <br/>make<br/>make install<br/>cd ..<br/>tar zvxf zlib-1.2.3.tar.gz <br/>cd zlib-1.2.3<br/>./configure --prefix=/usr/local/zlib<br/>make<br/>make install<br/>cd ..<br/>tar zxvf libpng-1.2.40.tar.gz<br/>cd libpng-1.2.40<br/>cp scripts/makefile.std makefile<br/>make <br/>make install<br/>cd ..<br/>tar xzvf gd-2.0.35.tar.gz<br/>cd gd-2.0.35<br/>./configure --prefix=/usr/local/gd --with-png=/usr/local/libpng --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6 --with-libxml=/usr/local/libxml2<br/>make （make的时候出报错，没关系，再make一次就可以）<br/>make install<br/>cd ..<br/>tar -zxvf libmcrypt-2.5.7.tar.gz<br/>cd libmcrypt-2.5.7<br/>./configure<br/>make<br/>make install<br/>cd ..<br/>ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la<br/>ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so<br/>ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4<br/>ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8<br/> <br/>这样就安装完成php常用的库了<br/>4、接着安装php、php-frm<br/> tar zxvf php-5.2.17.tar.gz<br/>gzip -cd php-5.2.17-fpm-0.5.14.diff.gz &#124; patch -d php-5.2.17 -p1<br/>cd php-5.2.17<br/>./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv=/usr/local/libiconv/ --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/zlib --with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --with-mysql=/usr/local/mysql --with-mcrypt=/usr/local/lib/libmcrypt --enable-mbstring --with-openssl --enable-ftp --with-curl --enable-fastcgi --enable-xml --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization&nbsp;&nbsp;--with-curlwrappers --enable-mbregex&nbsp;&nbsp;--enable-fpm --enable-force-cgi-redirect --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl<br/>make<br/>make install<br/>cp php.ini-dist /usr/local/php/lib/php.ini<br/> <br/>PHP的配置一会再说，先把nginx安装完成<br/>5、nginx及php扩展插件<br/> tar zxvf pcre-8.01.tar.gz<br/>cd pcre-8.01/<br/>./configure<br/>make <br/>make install<br/>cd ..<br/> <br/>groupadd www<br/>useradd -g www -d /home/www -s /sbin/nologin www<br/>tar zxvf nginx-0.9.5.tar.gz<br/>cd nginx-0.9.5/<br/>./configure --with-http_stub_status_module --with-http_ssl_module --user=www --group=www --with-http_realip_module<br/>make<br/>make install<br/>cd ..<br/>tar zxvf memcache-2.2.5.tgz<br/>cd memcache-2.2.5/<br/>/usr/local/php/bin/phpize<br/>./configure --with-php-config=/usr/local/php/bin/php-config<br/>make<br/>make install<br/>cd ..<br/>tar jxvf eaccelerator-0.9.5.3.tar.bz2<br/>cd eaccelerator-0.9.5.3/<br/>/usr/local/php/bin/phpize<br/>./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config<br/>make<br/>make install<br/>cd ..<br/>mkdir /tmp/eaccelerator<br/>chmod 777 /tmp/eaccelerator<br/>chown www:www /tmp/eaccelerator<br/> <br/>6、安装完那一大堆软件之后，要开始配置了，下面这些才是关键<br/>第一步：配置php.ini<br/> vi /usr/local/php/lib/php.ini<br/>找到<br/> extension_dir =""<br/>修改成<br/>extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"<br/>extension = "memcache.so"<br/>再找到<br/> output_buffering=off<br/>修改成<br/> output_buffering = On<br/>再次查找<br/> ; cgi.fix_pathinfo=0<br/>把注释去掉<br/>cgi.fix_pathinfo=0<br/>最后跳到php.ini文件的末尾，加入以下内容：<br/>[eaccelerator]<br/>zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"<br/>eaccelerator.shm_size="16"<br/>eaccelerator.cache_dir="/tmp/eaccelerator"<br/>eaccelerator.enable="1"<br/>eaccelerator.optimizer="1"<br/>eaccelerator.check_mtime="1"<br/>eaccelerator.debug="0"<br/>eaccelerator.filter=""<br/>eaccelerator.shm_max="0"<br/>eaccelerator.shm_ttl="0"<br/>eaccelerator.shm_prune_period="0"<br/>eaccelerator.shm_only="0"<br/>eaccelerator.compress="0"<br/>eaccelerator.compress_level="9"<br/>eaccelerator.keys = "disk_only"<br/>eaccelerator.sessions = "disk_only"<br/>eaccelerator.content = "disk_only"<br/>至此，php.ini文件修改完毕！<br/>第二步：配置nginx的FCGI<br/> vi /usr/local/nginx/conf/fcgi.conf<br/>写入以下内容：<br/>fastcgi_param&nbsp;&nbsp;GATEWAY_INTERFACE&nbsp;&nbsp;CGI/1.1;<br/>fastcgi_param&nbsp;&nbsp;SERVER_SOFTWARE&nbsp;&nbsp;&nbsp;&nbsp;nginx;<br/>fastcgi_param&nbsp;&nbsp;QUERY_STRING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $query_string;<br/>fastcgi_param&nbsp;&nbsp;REQUEST_METHOD&nbsp;&nbsp;&nbsp;&nbsp; $request_method;<br/>fastcgi_param&nbsp;&nbsp;CONTENT_TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $content_type;<br/>fastcgi_param&nbsp;&nbsp;CONTENT_LENGTH&nbsp;&nbsp;&nbsp;&nbsp; $content_length;<br/>fastcgi_param&nbsp;&nbsp;SCRIPT_FILENAME&nbsp;&nbsp;&nbsp;&nbsp;$document_root$fastcgi_script_name;<br/>fastcgi_param&nbsp;&nbsp;SCRIPT_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fastcgi_script_name;<br/>fastcgi_param&nbsp;&nbsp;REQUEST_URI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request_uri;<br/>fastcgi_param&nbsp;&nbsp;DOCUMENT_URI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $document_uri;<br/>fastcgi_param&nbsp;&nbsp;DOCUMENT_ROOT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$document_root;<br/>fastcgi_param&nbsp;&nbsp;SERVER_PROTOCOL&nbsp;&nbsp;&nbsp;&nbsp;$server_protocol;<br/>fastcgi_param&nbsp;&nbsp;REMOTE_ADDR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$remote_addr;<br/>fastcgi_param&nbsp;&nbsp;REMOTE_PORT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$remote_port;<br/>fastcgi_param&nbsp;&nbsp;SERVER_ADDR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$server_addr;<br/>fastcgi_param&nbsp;&nbsp;SERVER_PORT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$server_port;<br/>fastcgi_param&nbsp;&nbsp;SERVER_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$server_name;<br/># PHP only, required if PHP was built with --enable-force-cgi-redirect<br/>fastcgi_param&nbsp;&nbsp;REDIRECT_STATUS&nbsp;&nbsp;&nbsp;&nbsp;200;<br/>第三步：配置php-fpm文件<br/>mv /usr/local/php/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf.bak<br/> vi /root/lnmp/php-fpm.conf<br/>重新写入以下内容<br/><?xml version="1.0" ?><br/><configuration><br/>&nbsp;&nbsp;All relative paths in this config are relative to php's install prefix<br/>&nbsp;&nbsp;<section name="global_options"><br/>&nbsp;&nbsp;&nbsp;&nbsp;Pid file<br/>&nbsp;&nbsp;&nbsp;&nbsp;<value name="pid_file">/usr/local/php/logs/php-fpm.pid</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;Error log file<br/>&nbsp;&nbsp;&nbsp;&nbsp;<value name="error_log">/usr/local/php/logs/php-fpm.log</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;Log level<br/>&nbsp;&nbsp;&nbsp;&nbsp;<value name="log_level">notice</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;When this amount of php processes exited with SIGSEGV or SIGBUS ...<br/>&nbsp;&nbsp;&nbsp;&nbsp;<value name="emergency_restart_threshold">10</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;... in a less than this interval of time, a graceful restart will be initiated.<br/>&nbsp;&nbsp;&nbsp;&nbsp;Useful to work around accidental curruptions in accelerator's shared memory.<br/>&nbsp;&nbsp;&nbsp;&nbsp;<value name="emergency_restart_interval">1m</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;Time limit on waiting child's reaction on signals from master<br/>&nbsp;&nbsp;&nbsp;&nbsp;<value name="process_control_timeout">5s</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;Set to 'no' to debug fpm<br/>&nbsp;&nbsp;&nbsp;&nbsp;<value name="daemonize">yes</value><br/>&nbsp;&nbsp;</section><br/>&nbsp;&nbsp;<workers><br/>&nbsp;&nbsp;&nbsp;&nbsp;<section name="pool"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name of pool. Used in logs and stats.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="name">default</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Address to accept fastcgi requests on.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="listen_address">127.0.0.1:9000</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="listen_options"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set listen(2) backlog<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="backlog">-1</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set permissions for unix socket, if one used.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;In Linux read/write permissions must be set in order to allow connections from web server.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Many BSD-derrived systems allow connections regardless of permissions.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="owner"></value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="group"></value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="mode">0666</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Additional php.ini defines, specific to this pool of workers.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="php_defines"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="sendmail_path">/usr/sbin/sendmail -t -i</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="display_errors">0</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Unix user of processes<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="user">www</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Unix group of processes<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="group">www</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process manager settings<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="pm"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets style of controling worker process count.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Valid values are 'static' and 'apache-like'<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="style">static</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the limit on the number of simultaneous requests that will be served.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Equivalent to Apache MaxClients directive.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Used with any pm_style.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="max_children">128</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Settings group for 'apache-like' pm style<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="apache_like"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the number of server processes created on startup.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Used only when 'apache-like' pm_style is selected<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="StartServers">20</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the desired minimum number of idle server processes.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Used only when 'apache-like' pm_style is selected<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="MinSpareServers">5</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the desired maximum number of idle server processes.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Used only when 'apache-like' pm_style is selected<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="MaxSpareServers">35</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The timeout (in seconds) for serving a single request after which the worker process will be terminated<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Should be used when 'max_execution_time' ini option does not stop script execution for some reason<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'0s' means 'off'<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="request_terminate_timeout">0s</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'0s' means 'off'<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="request_slowlog_timeout">0s</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The log file for slow requests<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="slowlog">logs/slow.log</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set open file desc rlimit<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="rlimit_files">65535</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set max core size rlimit<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="rlimit_core">0</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Chroot to this directory at the start, absolute path<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="chroot"></value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Chdir to this directory at the start, absolute path<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="chdir"></value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Redirect workers' stdout and stderr into main error log.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If not set, they will be redirected to /dev/null, according to FastCGI specs<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="catch_workers_output">yes</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;How much requests each process should execute before respawn.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Useful to work around memory leaks in 3rd party libraries.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For endless request processing please specify 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Equivalent to PHP_FCGI_MAX_REQUESTS<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="max_requests">1024</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Makes sense only with AF_INET listening socket.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="allowed_clients">127.0.0.1</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pass environment variables like LD_LIBRARY_PATH<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;All $VARIABLEs are taken from current environment<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="environment"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="HOSTNAME">$HOSTNAME</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="PATH">/usr/local/bin:/usr/bin:/bin</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="TMP">/tmp</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="TMPDIR">/tmp</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="TEMP">/tmp</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="OSTYPE">$OSTYPE</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="MACHTYPE">$MACHTYPE</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<value name="MALLOC_CHECK_">2</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</value><br/>&nbsp;&nbsp;&nbsp;&nbsp;</section><br/>&nbsp;&nbsp;</workers><br/></configuration><br/>第四步：配置nginx.conf文件<br/>&nbsp;&nbsp;vi /usr/local/nginx/conf/nginx.conf<br/>写入以下内容<br/> user www www;<br/>worker_processes 8;<br/>worker_cpu_affinity 0001 0010 0100 1000 0001 0010 0100 1000;<br/>#error_log&nbsp;&nbsp;/usr/local/nginx/logs/error.log;<br/>#error_log&nbsp;&nbsp;/usr/local/nginx/logs/error.log&nbsp;&nbsp;notice;<br/>#error_log&nbsp;&nbsp;/usr/local/nginx/logs/error.log&nbsp;&nbsp;info;<br/>#pid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logs/nginx.pid;<br/>worker_rlimit_nofile 204800;<br/>events &#123;<br/> use epoll;<br/> worker_connections 204800;<br/>&#125;<br/>http &#123;<br/> include&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mime.types;<br/> default_type&nbsp;&nbsp;application/octet-stream;<br/> #log_format&nbsp;&nbsp;main&nbsp;&nbsp;'$remote_addr - $remote_user [$time_local] "$request" '<br/> #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'$status $body_bytes_sent "$http_referer" '<br/> #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'"$http_user_agent" "$http_x_forwarded_for"';<br/> #access_log&nbsp;&nbsp;logs/access.log&nbsp;&nbsp;main;<br/> sendfile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;on;<br/> tcp_nopush&nbsp;&nbsp;&nbsp;&nbsp; on;<br/> tcp_nodelay&nbsp;&nbsp;&nbsp;&nbsp;on;<br/> keepalive_timeout&nbsp;&nbsp;60;<br/> #ip_hash;<br/> ignore_invalid_headers&nbsp;&nbsp; on;<br/> recursive_error_pages&nbsp;&nbsp;&nbsp;&nbsp;on;<br/> server_name_in_redirect off;<br/> server_tokens&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; off;<br/> gzip on;<br/> gzip_comp_level&nbsp;&nbsp;9;<br/> gzip_min_length&nbsp;&nbsp;1100;<br/> gzip_buffers&nbsp;&nbsp;4 8k;<br/> gzip_http_version&nbsp;&nbsp;1.1;<br/> gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;<br/> server_names_hash_bucket_size 256;<br/> client_header_buffer_size 16K;<br/> large_client_header_buffers 4 64k;<br/> client_max_body_size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50m;<br/> client_body_buffer_size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;256k;<br/> client_header_timeout&nbsp;&nbsp;&nbsp;&nbsp; 3m;<br/> client_body_timeout 3m;<br/> send_timeout&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3m;<br/> open_file_cache max=204800 inactive=20s;<br/> open_file_cache_min_uses 1;<br/> open_file_cache_valid 30s;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/> server<br/> &#123;<br/>&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 80;<br/>&nbsp;&nbsp;server_name lihuipeng.blog.51cto.com;<br/>&nbsp;&nbsp;index index.html index.php;<br/>&nbsp;&nbsp;root&nbsp;&nbsp;/home/www/blog;<br/>&nbsp;&nbsp;access_log&nbsp;&nbsp;/home/logs/access_lihuipeng.blog.51cto.com.log;<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;if (-d $request_filename)&#123;<br/>&nbsp;&nbsp; rewrite ^/(.*)([^/])$ <a href="http://$host/$1$2/" target="_blank">http://$host/$1$2/</a> permanent;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;error_page&nbsp;&nbsp; 500 502 503 504 404 403 <a href="http://lihuipeng.blog.51cto.com;" target="_blank">http://lihuipeng.blog.51cto.com;</a><br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;location ~ .*&#92;.(gif&#124;jpg&#124;jpeg&#124;png&#124;bmp&#124;swf)$ &#123;<br/>&nbsp;&nbsp; expires 30d;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;location ~ .*&#92;.(js&#124;css)?$ &#123;<br/>&nbsp;&nbsp; expires 6h;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;location ~ .*&#92;.(log&#124;txt)$<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp; deny all;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp; location ~ .*&#92;.(php)?$<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp; fastcgi_pass&nbsp;&nbsp;127.0.0.1:9000;<br/>&nbsp;&nbsp; fastcgi_index index.php;<br/>&nbsp;&nbsp; include fcgi.conf;<br/>&nbsp;&nbsp;&#125;<br/> &#125;<br/>&#125;<br/> <br/>7、启动服务<br/>/usr/local/php/sbin/php-fpm start<br/>/usr/local/nginx/sbin/nginx<br/>看看有没启动成功<br/> [root@localhost ~]# netstat -tunlp<br/>Active Internet connections (only servers)<br/>Proto Recv-Q Send-Q Local Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Foreign Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PID/Program name&nbsp;&nbsp; <br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 127.0.0.1:199&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3937/snmpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 127.0.0.1:9000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3954/php-cgi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 0.0.0.0:3306&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2662/mysqld&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 0.0.0.0:80&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;18066/nginx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 0.0.0.0:21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;17955/vsftpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 127.0.0.1:25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4137/sendmail: acce <br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 :::5989&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :::*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2714/cimserver&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 :::22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :::*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2574/sshd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 0.0.0.0:161&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3937/snmpd <br/>看见php-cgi和nginx端口在正常监听！<br/>本文出自 “疯狂的猴子” 博客，请务必保留此出处<a href="http://lihuipeng.blog.51cto.com/3064864/561862" target="_blank">http://lihuipeng.blog.51cto.com/3064864/561862</a>
]]>
</description>
</item><item>
<link>http://blog.hackroad.com/read.php/496.htm</link>
<title><![CDATA[linux nginx php木马排查及加固整理]]></title> 
<author>chen &lt;fanmaochen@gmail.com&gt;</author>
<category><![CDATA[Server]]></category>
<pubDate>Wed, 18 Jan 2012 09:31:53 +0000</pubDate> 
<guid>http://blog.hackroad.com/read.php/496.htm</guid> 
<description>
<![CDATA[ 
	linux nginx php木马排查及加固整理<br/>1、改变目录和文件属性，禁止写入<br/> find -type f -name &#92;*.php -exec chmod 444 &#123;&#125; &#92;;<br/> find -type d -exec chmod 555 &#123;&#125; &#92;; <br/> 注：当然要排除上传目录、缓存目录等；<br/> 同时最好禁止chmod函数，攻击者可通过chmod来修改文件只读属性再修改文件<br/>2、php配置<br/> 禁用危险函数<br/> passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,<br/> ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,popen,dl,<br/> syslog,show_source<br/>3、nginx配置<br/> 限制一些目录执行php文件<br/>&nbsp;&nbsp;location~^/images/.*&#92;.(php&#124;php5)$<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;denyall;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;location~^/static/.*&#92;.(php&#124;php5)$<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;denyall;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;location~*^/data/(attachment&#124;avatar)/.*&#92;.(php&#124;php5)$<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;denyall;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;注：这些目录的限制必须写在<br/>&nbsp;&nbsp; location~.*&#92;.(php&#124;php5)$<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp; fastcgi_pass127.0.0.1:9000;<br/>&nbsp;&nbsp;&nbsp;&nbsp; fastcgi_indexindex.php;<br/>&nbsp;&nbsp;&nbsp;&nbsp; include fcgi.conf;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp; 的前面，否则限制不生效<br/><br/> path_info漏洞修正：<br/>&nbsp;&nbsp;在通用fcgi.conf顶部加入<br/>&nbsp;&nbsp;if ($request_filename ~* (.*)&#92;.php) &#123;<br/>&nbsp;&nbsp;set $php_url $1;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;if (!-e $php_url.php) &#123;<br/>&nbsp;&nbsp;return 404;<br/>&nbsp;&nbsp;&#125;<br/>4、木马查找<br/>&nbsp;&nbsp;php木马一般含有<?php eval($_POST[cmd]);?>或者<?php assert($_POST[cmd]);?><br/>&nbsp;&nbsp;find /data/wwwroot/* -type f -name "*.php" &#124;xargs grep "eval(" > /root/scan.txt <br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;还有<br/>&nbsp;&nbsp; 常见的一句话后门：<br/>&nbsp;&nbsp; grep -r --include=*.php&nbsp;&nbsp;'[^a-z]eval($_POST' . > grep.txt<br/>&nbsp;&nbsp; grep -r --include=*.php&nbsp;&nbsp;'file_put_contents(.*$_POST&#92;[.*&#92;]);' . > grep.txt<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; 把搜索结果写入文件，下载下来慢慢分析，其他特征木马、后门类似。有必要的话可对全站所有文件来一次特征查找，上传图片肯定有也捆绑的，来次大清洗。<br/>5、查找近3天被修改过的文件：<br/> find /data/www -mtime -3 -type f -name &#92;*.php<br/>&nbsp;&nbsp;注意：攻击者可能会通过touch函数来修改文件时间属性来避过这种查找，所以touch必须禁止
]]>
</description>
</item>
</channel>
</rss>
