<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WilliamGates Blog &#187; NOD32</title>
	<atom:link href="http://blog.williamgates.biz/tag/nod32/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.williamgates.biz</link>
	<description>四片叶子的三叶草</description>
	<lastBuildDate>Fri, 11 Nov 2011 14:32:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>NOD32升级服务器——WG个人提供</title>
		<link>http://blog.williamgates.biz/2009/02/wg-nod32-update-server/</link>
		<comments>http://blog.williamgates.biz/2009/02/wg-nod32-update-server/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 03:23:37 +0000</pubDate>
		<dc:creator>WG</dc:creator>
				<category><![CDATA[LilyStudio]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[技术心得]]></category>
		<category><![CDATA[NOD32]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[折腾]]></category>
		<category><![CDATA[服务]]></category>

		<guid isPermaLink="false">http://blog.williamgates.biz/?p=322</guid>
		<description><![CDATA[　　试着公布一下我自己建的NOD32升级服务器（仅限v3，测试阶段，可能不稳定，随时可能改密码）： 　　地址：http://nod32.williamgates.biz 　　用户名：williamgates 　　密码：nodnod 　　密码可能常常修改，修改规则未定，一旦不能升级请及时来看本帖，所有修改都将在本帖发布。 Related posts: 再谈不要乱改Android的hosts文件 慎改Android的Hosts文件 在国行双网机（如i909/i809）上使用Android Market购买app研究小结]]></description>
			<content:encoded><![CDATA[<p>　　试着公布一下我自己建的NOD32升级服务器（仅限v3，测试阶段，可能不稳定，随时可能改密码）：</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">　　地址：http://nod32.williamgates.biz
　　用户名：williamgates
　　密码：nodnod</pre></div></div>

<p>　　密码可能常常修改，修改规则未定，一旦不能升级请及时来看本帖，所有修改都将在本帖发布。</p>
<p>Related posts:<ol>
<li><a href='http://blog.williamgates.biz/2011/11/do-not-and-do-not-edit-hosts-of-android/' rel='bookmark' title='再谈不要乱改Android的hosts文件'>再谈不要乱改Android的hosts文件</a></li>
<li><a href='http://blog.williamgates.biz/2011/09/do-not-edit-hosts-of-android-unless-necessary/' rel='bookmark' title='慎改Android的Hosts文件'>慎改Android的Hosts文件</a></li>
<li><a href='http://blog.williamgates.biz/2011/10/how-to-purchase-android-apps-use-i809-at-mainland-china/' rel='bookmark' title='在国行双网机（如i909/i809）上使用Android Market购买app研究小结'>在国行双网机（如i909/i809）上使用Android Market购买app研究小结</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.williamgates.biz/2009/02/wg-nod32-update-server/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>在虚拟主机上架设NOD32升级服务器</title>
		<link>http://blog.williamgates.biz/2009/02/setup-nod32-update-server-on-hostmonster/</link>
		<comments>http://blog.williamgates.biz/2009/02/setup-nod32-update-server-on-hostmonster/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 03:16:00 +0000</pubDate>
		<dc:creator>WG</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[技术心得]]></category>
		<category><![CDATA[HostMonster]]></category>
		<category><![CDATA[NOD32]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[折腾]]></category>
		<category><![CDATA[虚拟主机]]></category>

		<guid isPermaLink="false">http://blog.williamgates.biz/?p=317</guid>
		<description><![CDATA[　　常给朋友和同事推荐NOD32，但是给他们装的时候往往没有升级服务器可用，他们既不会自己上网去搜索一些免费的升级地址，我也不大方便把drl的服务器给他们用——于是决定自己架设一个。 　　自己没有架在公众网的服务器，只有虚拟主机，到底能不能做到呢？下面就以我的HostMonster主机为例，来一步步尝试。 　　所需条件：支持SSH、cron的主机。 　　一、安装unrar 　　nod32升级的第一步就是下载update.ver文件，这是一个更新包的列表文件，用于增量升级。要命的是这个文件是rar包——天知道他们怎么想的——绝大多数商业的虚拟主机由于版权的原因不可能预装rar，所以我们只能自己装一个。 　　首先创建一个目录，建议在public_html之外，即无法通过apache访问到的目录，用于存放rarlinux程序文件。然后从官方网站下载rarlinux http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz 　　解压 tar zxvf rarlinux-3.6.0.tar.gz 　　这里要注意的是，Debian系统用3.6以下或以上的版本都会出现库文件错误，只有3.6不需要任何折腾就能使用，反正只是用来解压缩一个文件，还是老老实实用3.6吧。 　　解压之后得到rar目录，unrar就在目录中，无须安装，由于没有权限，就不要用make install了，反正不安装也能用。 　　二、编写升级脚本 　　这里使用php脚本自动从升级服务器下载文件，假设wget在系统中路径是/usr/bin/wget，unrar（刚才解压出来的地址）是/home/rar/unrar，我们升级文件的绝对路径为/home/public_html/nod32/，实际公开的地址是nod32.a.com，上层升级服务器是nod32.b.com/nod32/，用户名a，密码b（以上全都是虚构），那么脚本如下（抄袭自drl的jindui，根据我的情况略有修改，并修改了一处BUG） 　　文件&#8221;v3.php&#8221; &#60; ? $base='/home/public_html/nod32/'; $LOCALDIR = $base; $UPDATEDIR = $base; $TEMPDIR = $base.'tmp/'; $WGET = &#34;/usr/bin/wget --user-agent='ESS Update (Windows; U; 32bit; VDB 1924; BPC 3; OS: 6.0.6000 SP 0.0 NT; CH 1.1; LNG 1033; x32c;' &#34;; $UNRAR = '/home/rar/unrar'; [...]]]></description>
			<content:encoded><![CDATA[<p>　　常给朋友和同事推荐NOD32，但是给他们装的时候往往没有升级服务器可用，他们既不会自己上网去搜索一些免费的升级地址，我也不大方便把drl的服务器给他们用——于是决定自己架设一个。<br />
　　自己没有架在公众网的服务器，只有虚拟主机，到底能不能做到呢？下面就以我的HostMonster主机为例，来一步步尝试。<br />
　　所需条件：支持SSH、cron的主机。</p>
<p>　　一、安装unrar<br />
　　nod32升级的第一步就是下载update.ver文件，这是一个更新包的列表文件，用于增量升级。要命的是这个文件是rar包——天知道他们怎么想的——绝大多数商业的虚拟主机由于版权的原因不可能预装rar，所以我们只能自己装一个。<br />
　　首先创建一个目录，建议在public_html之外，即无法通过apache访问到的目录，用于存放rarlinux程序文件。然后从官方网站下载rarlinux</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">http:<span style="color: #000000; font-weight: bold;">//</span>www.rarlab.com<span style="color: #000000; font-weight: bold;">/</span>rar<span style="color: #000000; font-weight: bold;">/</span>rarlinux-3.6.0.tar.gz</pre></div></div>

<p>　　解压</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf rarlinux-3.6.0.tar.gz</pre></div></div>

<p>　　这里要注意的是，Debian系统用3.6以下或以上的版本都会出现库文件错误，只有3.6不需要任何折腾就能使用，反正只是用来解压缩一个文件，还是老老实实用3.6吧。<br />
　　解压之后得到rar目录，unrar就在目录中，无须安装，由于没有权限，就不要用make install了，反正不安装也能用。</p>
<p>　　二、编写升级脚本<br />
　　这里使用php脚本自动从升级服务器下载文件，假设wget在系统中路径是/usr/bin/wget，unrar（刚才解压出来的地址）是/home/rar/unrar，我们升级文件的绝对路径为/home/public_html/nod32/，实际公开的地址是nod32.a.com，上层升级服务器是nod32.b.com/nod32/，用户名a，密码b（以上全都是虚构），那么脚本如下（抄袭自drl的jindui，根据我的情况略有修改，并修改了一处BUG）<br />
<span id="more-317"></span><br />
　　文件&#8221;v3.php&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ? 
<span style="color: #000088;">$base</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'/home/public_html/nod32/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$LOCALDIR</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$base</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$UPDATEDIR</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$base</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$TEMPDIR</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$base</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'tmp/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$WGET</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/usr/bin/wget  --user-agent='ESS Update (Windows; U; 32bit; VDB 1924; BPC 3; OS: 6.0.6000 SP 0.0 NT; CH 1.1; LNG 1033; x32c;' &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$UNRAR</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/home/rar/unrar'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$UPDATE_SERVER</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://nod32.b.com/'</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$updateurl</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">${UPDATE_SERVER}</span>/nod32/update.ver&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;nod32.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>　　文件&#8221;nod32.php&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ? 
<span style="color: #000088;">$UNRAR</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/home/rar/unrar'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$update</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">${UPDATEDIR}</span>update.ver&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$updatetmp</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">${UPDATEDIR}</span>update.tmp&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$USER</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'a'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$PASS</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'b'</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">//$ignore = array('fr.nup', 'ge.nup', 'it.nup', 'jp.nup', 'pl.nup', 'pt.nup', 'sk.nup', 'sp.nup', 'hr.nup', 'hu.nup', 'nl.nup'); </span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$LOCALDIR</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$LOCALDIR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UPDATEDIR</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UPDATEDIR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$TEMPDIR</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$TEMPDIR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//copy($update,$updatetmp);</span>
<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$WGET</span> -t 15 -T 60 -N -nH -nd -P <span style="color: #006699; font-weight: bold;">$UPDATEDIR</span> <span style="color: #006699; font-weight: bold;">$updateurl</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">/*$md51=exec(&quot;md5 -q $update&quot;);
$md52=exec(&quot;md5 -q $updatetmp&quot;);
unlink($updatetmp);
&nbsp;
if($md51==$md52) {
         echo &quot;no update need   !&quot;;
        exit;
&nbsp;
}*/</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ret</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Failed while downloading update.ver.'</span><span style="color: #339933;">;</span> 
    <span style="color: #990000;">exit</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$UNRAR</span> x -y -o+ <span style="color: #006699; font-weight: bold;">{$UPDATEDIR}</span>update.ver <span style="color: #006699; font-weight: bold;">{$TEMPDIR}</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$TEMPDIR}</span>update.ver&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/file=(\/[\/a-z0-9\-\_\.]+)\W+size=([0-9]+)\W/ise&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$list</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$num</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//这句话我修改了一下，将字符串开头的&quot;/&quot;去掉了</span>
<span style="color: #666666; font-style: italic;">//否则地址会有两个&quot;/&quot;，造成文件大小无法比对，每次都会重新下载全部的文件）</span>
    <span style="color: #000088;">$size</span><span style="color: #339933;">=</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$filesize</span><span style="color: #339933;">=</span><span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$base</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #339933;">!=</span><span style="color: #000088;">$filesize</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$list</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$UPDATE_SERVER}</span><span style="color: #006699; font-weight: bold;">$file</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;the file size of   <span style="color: #006699; font-weight: bold;">$file</span>  is same, skip <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
preg_match_all(&quot;/file=(.+?)\n/ie&quot;, $content, $matches); 
&nbsp;
$list = ''; 
foreach($matches[1] as $match) { 
    $match = trim($match); 
    $last = substr($match, -6); 
&nbsp;
    if (!in_array($last, $ignore)) 
        $list .= &quot;{$UPDATE_SERVER}$match\r\n&quot;; 
} */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#file_put_contents('list.txt', $list); 
</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;list.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$list</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$WGET</span> --http-user=<span style="color: #006699; font-weight: bold;">$USER</span> --http-passwd=<span style="color: #006699; font-weight: bold;">$PASS</span> -t 15  -T 60 -m -nH -P <span style="color: #006699; font-weight: bold;">$LOCALDIR</span> -i list.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ret</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Failed while downloading files.'</span><span style="color: #339933;">;</span> 
    <span style="color: #990000;">exit</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Updated successfully.'</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>　　现在从浏览器访问v3.php（这两个脚本无所谓放在哪里，只要是能通过apache访问到的目录就行，建议单独设置目录以便我们下面说的安全保护），就已经可以成功下载文件了。</p>
<p>　　三、安全保护<br />
　　为了不让普通用户主动运行升级脚本，也不让别人可以查看你的上层升级服务器的地址，我选择了密码保护，直接在HostMonster的控制面板里设置就行了，否则自己写文件有点麻烦。对你存放v3.php和nod32.php的目录设置一个用户名和密码，我们这里假设用户名是abc，密码是123。将一个单独的子域名（例如abc.a.com）指向这个目录。用浏览器访问就会弹出提示输入用户名密码的对话框。这无所谓，反正我们只要用lynx就行——一个Linux命令行下的浏览器（其实wget也行）。<br />
　　运行这个命令</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">lynx</span> <span style="color: #660033;">-cfg</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #660033;">-source</span> <span style="color: #660033;">-auth</span>=abc:<span style="color: #000000;">123</span> http:<span style="color: #000000; font-weight: bold;">//</span>abc.a.com<span style="color: #000000; font-weight: bold;">/</span>v3.php</pre></div></div>

<p>　　其中-cfg参数是指定配置文件，这里指定为空（否则会出错），-source表示纯字符串输出，-auth是密码验证的功能。<br />
　　可以看到输出一串结果，说明下载成功或者文件已存在不用下载。<br />
　　然后用同样的方法对下载来的文件存放的目录即本例中的/home/public_html/nod32/设置一个密码，是用来发布给别人升级时用的，记得不要和前面那个一样哦。</p>
<p>　　四、定时运行任务<br />
　　要让php脚本定时运行，虽然也可以用CGI方式运行php，但是我还是倾向于用浏览器，这样较为安全。<br />
　　编写一个nod32.sh文件（假设你的sh在/bin/，lynx在/usr/bin/，不清楚的话可以用whereis sh查到），同样放在apache无法取到的目录下，假设还是放在/home/rar/</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">lynx</span> <span style="color: #660033;">-cfg</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #660033;">-source</span> <span style="color: #660033;">-auth</span>=abc:<span style="color: #000000;">123</span> http:<span style="color: #000000; font-weight: bold;">//</span>abc.a.com<span style="color: #000000; font-weight: bold;">/</span>v3.php</pre></div></div>

<p>　　然后在虚拟主机的控制面板里设置Cron任务，更新频率每12小时吧，命令为</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>rar<span style="color: #000000; font-weight: bold;">/</span>nod32.sh</pre></div></div>

<p>　　这样就完成了，你的程序会自动定时去上层服务器下载升级文件并存放在/home/public_html/nod32/，你只需要设置nod32.a.com指向该目录，就可以公开发布这个地址了。</p>
<p>　　最后，公布一下我自己建的<a href="http://blog.williamgates.biz/2009/02/wg-nod32-update-server/">NOD32升级服务器</a><br />
　　</p>
<p>Related posts:<ol>
<li><a href='http://blog.williamgates.biz/2011/09/do-not-edit-hosts-of-android-unless-necessary/' rel='bookmark' title='慎改Android的Hosts文件'>慎改Android的Hosts文件</a></li>
<li><a href='http://blog.williamgates.biz/2011/10/how-to-purchase-android-apps-use-i809-at-mainland-china/' rel='bookmark' title='在国行双网机（如i909/i809）上使用Android Market购买app研究小结'>在国行双网机（如i909/i809）上使用Android Market购买app研究小结</a></li>
<li><a href='http://blog.williamgates.biz/2011/11/do-not-and-do-not-edit-hosts-of-android/' rel='bookmark' title='再谈不要乱改Android的hosts文件'>再谈不要乱改Android的hosts文件</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.williamgates.biz/2009/02/setup-nod32-update-server-on-hostmonster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

