<?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>小惡魔 - 電腦技術 - 生活日記 - 美食介紹 - AppleBOY &#187; FreeBSD</title>
	<atom:link href="http://blog.wu-boy.com/category/%e9%9b%bb%e8%85%a6%e6%8a%80%e8%a1%93/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.wu-boy.com</link>
	<description>介紹一堆美食日記，生活日記，電腦筆記</description>
	<lastBuildDate>Tue, 27 Jul 2010 14:04:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ProFTPD UseEncoding 繁體中文亂碼解決 Localization</title>
		<link>http://blog.wu-boy.com/2010/07/07/2276/</link>
		<comments>http://blog.wu-boy.com/2010/07/07/2276/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 08:07:13 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proftpd]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=2276</guid>
		<description><![CDATA[ProFTPD 一直都是我最喜歡使用的 FTP 伺服器，設定方式簡單淺顯易懂，最近在用 PSPad 寫程式，發現使用內建 FTP 功能時候，連不上 FreeBSD 架設的 ProFTPD，連線過程出現許多亂碼，所以造成 PSPad 斷線出現錯誤，解決方式就是利用 mod_lang 模組，設定 UseEncoding 讓系統可以顯示 Big5 中文編碼，FreeBSD Ports 請勾選
<span class="readmore"><a href="http://blog.wu-boy.com/2010/07/07/2276/" title="ProFTPD UseEncoding 繁體中文亂碼解決 Localization" target="_blank">...詳全文（共618字）</a></span>]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm5.static.flickr.com/4096/4770121725_6a997912c6_o.png" alt="Proftpd" /><br />
<a href="http://www.proftpd.org/">ProFTPD</a> 一直都是我最喜歡使用的 FTP 伺服器，設定方式簡單淺顯易懂，最近在用 <a href="http://www.pspad.com/">PSPad</a> 寫程式，發現使用內建 FTP 功能時候，連不上 <a href="http://www.freebsd.org">FreeBSD</a> 架設的 ProFTPD，連線過程出現許多亂碼，所以造成 PSPad 斷線出現錯誤，解決方式就是利用 <a href="http://www.proftpd.org/docs/modules/mod_lang.html">mod_lang</a> 模組，設定 <a href="http://www.proftpd.org/docs/modules/mod_lang.html#UseEncoding">UseEncoding</a> 讓系統可以顯示 Big5 中文編碼，FreeBSD Ports 請勾選</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="br0">&#91;</span>X<span class="br0">&#93;</span> NLSUOTA Use nls <span class="br0">&#40;</span>builds mod_lang<span class="br0">&#41;</span></div></div>
<p>自行編譯請按照底下步驟</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">.<span class="sy0">/</span>configure <span class="re5">--enable-nls</span><br />
<span class="kw2">make</span><br />
<span class="kw2">make</span> <span class="kw2">install</span></div></div>
<h3>UseEncoding 設定</h3>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">Syntax: UseEncoding on<span class="sy0">|</span>off<span class="sy0">|</span>local-charset client-charset<br />
Default: None<br />
Context: <span class="st0">&quot;server config&quot;</span>, <span class="sy0">&lt;</span>VirtualHost<span class="sy0">&gt;</span>, <span class="sy0">&lt;</span>Global<span class="sy0">&gt;</span><br />
Module: mod_lang<br />
Compatibility: 1.3.2rc1</div></div>
<p>在 1.3.2rc1 版本之後才有支援，請複製底下設定，貼到 proftpd.conf</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0"># 简体中文環境</span><br />
UseEncoding UTF-<span class="nu0">8</span> GBK<br />
<span class="co0"># 繁体中文環境</span><br />
UseEncoding UTF-<span class="nu0">8</span> Big5</div></div>
<p>Reference:<br />
<a href="http://www.proftpd.org/docs/modules/mod_lang.html">ProFTPD module mod_lang</a><br />
<a href="http://wanglq.blog.51cto.com/783560/340741">centos上解決proftp中文亂碼問題</a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9">[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/26/2087/" title="Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)">Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf) (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros">[Vim] 想套用 *.php syntax 顏色於 *.ros (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/11/2041/" title="[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項">[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/01/08/1950/" title="[FreeBSD] Fanout and Fanterm Tool to run commands on multiple machines">[FreeBSD] Fanout and Fanterm Tool to run commands on multiple machines (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/29/1918/" title="[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)">[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/12/1901/" title="[UNIX] Vim 命令圖解說明">[UNIX] Vim 命令圖解說明 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/10/1894/" title="[FreeBSD] freebsd kernel: fxp0: link state changed to DOWN / UP">[FreeBSD] freebsd kernel: fxp0: link state changed to DOWN / UP (0)</a></li><li><a href="http://blog.wu-boy.com/2009/11/18/1843/" title="[FreeBSD] port committer 快速建立 pkg-plist">[FreeBSD] port committer 快速建立 pkg-plist (1)</a></li><li><a href="http://blog.wu-boy.com/2009/11/03/1781/" title="[Perl&#038;PHP] time() and Class::Date 日期轉換運算">[Perl&#038;PHP] time() and Class::Date 日期轉換運算 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2010/07/07/2276/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[FreeBSD] update apache -&gt; 2.2.15, PHP -&gt; 5.3.2, and MySQL downgrade to 5.1.9</title>
		<link>http://blog.wu-boy.com/2010/06/23/2240/</link>
		<comments>http://blog.wu-boy.com/2010/06/23/2240/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 05:46:34 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=2240</guid>
		<description><![CDATA[昨天升級了 FreeBSD 的 Apache, PHP, and MySQL，遇到很多地雷阿，最多的就是 PHP 的部份，因為本來自己使用 5.2.11 版本，但是在 commit port 的時候發生去裝 5.3.2 版本，所以就直接砍掉全部重練，先是遇到 MySQL 問題，原先在 database/mysql60-server 已經被 FreeBSD 移除，任何關於 mysql60 的相關 port 都被 remove 掉了，只好 downgrade 到 mysql 5.1.48 版本，移除同時順手把 apache PHP 相關都拿掉了。
<span class="readmore"><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9" target="_blank">...詳全文（共2543字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>昨天升級了 <a href="http://www.freebsd.org">FreeBSD</a> 的 Apache, <a href="http://www.php.net">PHP</a>, and <a href="http://www.mysql.com/">MySQL</a>，遇到很多地雷阿，最多的就是 PHP 的部份，因為本來自己使用 5.2.11 版本，但是在 commit port 的時候發生去裝 5.3.2 版本，所以就直接砍掉全部重練，先是遇到 MySQL 問題，原先在 database/mysql60-server 已經被 FreeBSD 移除，任何關於 mysql60 的相關 port 都被 remove 掉了，只好 downgrade 到 mysql 5.1.48 版本，移除同時順手把 apache PHP 相關都拿掉了。</p>
<h3>移除 apache mysql php 相關 ports</h3>
<p>-rf 依序找尋相關 Mysql ports 移除</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">pkg_deinstall <span class="re5">-rf</span> mysql60-server</div></div>
<p>接下來安裝 MySQL 5.1.48 Server and Client，可以找到在 <span style="color:green">databases/mysql51-server</span> and <span style="color:green">databases/mysql51-client</span>，直接安裝即可</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> <span class="sy0">/</span>usr<span class="sy0">/</span>ports<span class="sy0">/</span>databases<span class="sy0">/</span>mysql51-server <span class="sy0">&amp;&amp;</span> <span class="kw2">make</span> <span class="kw2">install</span></div></div>
<p>安裝 Apache 2.2.15</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> <span class="sy0">/</span>usr<span class="sy0">/</span>ports<span class="sy0">/</span>www<span class="sy0">/</span>apache22 <span class="sy0">&amp;&amp;</span> <span class="kw2">make</span> <span class="re2">WITH_MPM</span>=worker <span class="kw2">install</span></div></div>
<p>安裝 PHP 5.3.2，FreeBSD 把 5.2.X 跟 5.3.X 分開不同資料夾 <span style="color:green">lang/php5</span>, <span style="color:green">lang/php52</span>，extension 也是分成兩個，所以要安裝 5.2 版本也是可以的</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> <span class="sy0">/</span>usr<span class="sy0">/</span>ports<span class="sy0">/</span>lang<span class="sy0">/</span>php5 <span class="sy0">&amp;&amp;</span> <span class="kw2">make</span> <span class="kw2">install</span><br />
<span class="kw3">cd</span> <span class="sy0">/</span>usr<span class="sy0">/</span>ports<span class="sy0">/</span>lang<span class="sy0">/</span>php5-extensions<span class="sy0">/</span> <span class="sy0">&amp;&amp;</span> <span class="kw2">make</span> <span class="kw2">install</span></div></div>
<p>以上安裝好，就是苦難的開始，首先 MySQL 從原本的 6.0.9 降到 5.1.48，造成所有資料庫無法讀取，也沒辦法正確啟動 MySQL，馬上噴出底下問題：</p>
<blockquote><p>090205 11:14:24 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql<br />
/usr/local/libexec/mysqld: Unknown collation &#8216;#46&#8242; in table &#8216;plugin&#8217; definition<br />
090205 11:14:24 [ERROR] Can&#8217;t open the mysql.plugin table. Please run mysql_upgrade to create it.<br />
090205 11:14:24  InnoDB: Started; log sequence number 0 46429<br />
090205 11:14:24 [ERROR] Fatal error: Can&#8217;t open and lock privilege tables: <span style="color:red"><strong>Unknown collation &#8216;#46&#8242; in table &#8216;host&#8217;</strong></span> definition</p></blockquote>
<p>為啥會出現紅色那段字，就是因為字元集不同，MySQL 6 有支援 <span style="color:green">utf8mb4</span>，但是 5.1.48 版本沒有，所以才會造成無法啟動，解決方法呢？就是把 <span style="color:green">/var/db/mysql/mysql</span> 砍掉，在重新啟動就可以了，當然您的資料庫也是無法使用，再去其他電腦裝上 MySQL 6.0.9 之後，把 <span style="color:green">/var/db/mysql/</span> 底下的資料庫 Copy 過去一份，利用 mysqldump 把全部資料庫 dump 下來，再 restore 回去原來的系統，大致上就可以了。</p>
<p>對於把 PHP 升級到 5.3 的時候，心裡就在想會遇到很多雷，果然是如此，很多 opensource 都尚未支援到 php 5.3，也因此很多函數都無法支援，<span style="color:red">ereg_</span> 系列都必須換成 <span style="color:red">preg_</span>，<span style="color:green">register_globals</span> 的移除，也不能使用 HTTP_GET or HTTP_POST，把 <span style="color:green">register_long_arrays</span> 拿掉，參考: <a href="http://php.net/manual/en/ini.core.php">http://php.net/manual/en/ini.core.php</a>，<a href="http://codeigniter.com">CodeIgniter</a> V 1.7.2 開始支援 PHP 5.3.0 版本，這樣大致上所有專案都可以順利啟動，底下是在 Wordpress 遇到的問題：</p>
<blockquote><p>Warning: strtotime() [function.strtotime]: It is not safe to rely on the system&#8217;s timezone settings. <span style="color:red"><strong>You are *required* to use the date.timezone setting or the date_default_timezone_set() function.</strong></span> In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected &#8216;Europe/Helsinki&#8217; for &#8216;EEST/3.0/DST&#8217; instead in /path/to/my/www/wp-includes/functions.php on line 35</p></blockquote>
<p>這在 <a href="http://wordpress.org/">Wordpress</a> 官網也是有<a href="http://wordpress.org/support/topic/285337">提出此問題</a>，解決方式有兩種，一種是在 wp-config.php 加上 <span style="color:green">date_default_timezone_set(&#8217;</span>UTC<span style="color:green">&#8216;);</span> 或者是 <span style="color:green">date_default_timezone_set(&#8217;</span>Asia/Taipei<span style="color:green">&#8216;);</span>，另一種是修改 php.ini，修改</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">;</span> Defines the <span class="kw2">default</span> timezone used by the <a href="http://www.php.net/date"><span class="kw3">date</span></a> functions<br />
<a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="sy0">.</span>timezone <span class="sy0">=</span> Asia<span class="sy0">/</span>Taipei</div></div>
<p>這樣大致上修補完成，其他程式的修改這裡就不補充了，底下是 PHP 網站所支援的 time zone，可以參考看看其他時區</p>
<p>Reference:<br />
<a href="http://wordpress.org/support/topic/285337">Php 5.3.0 &#038; WP 2.8 (It is not safe to rely on the system&#8217;s timezone)</a><br />
<a href="http://php.net/manual/en/ini.core.php">Description of core php.ini directives</a><br />
<a href="http://blog.gslin.org/archives/2007/09/25/1318/">現在寫 PHP6-compatible 的一些技巧</a><br />
<a href="http://nl3.php.net/manual/en/timezones.php">List of Supported Timezones</a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2009/06/11/1386/" title="[網站] 好站連結 (三)">[網站] 好站連結 (三) (0)</a></li><li><a href="http://blog.wu-boy.com/2008/09/13/388/" title="[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi">[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi (3)</a></li><li><a href="http://blog.wu-boy.com/2008/07/01/286/" title="[FreeBSD]Apache 噴出 signal Segmentation fault (11)">[FreeBSD]Apache 噴出 signal Segmentation fault (11) (1)</a></li><li><a href="http://blog.wu-boy.com/2008/06/18/281/" title="基本優化 tuning apache 跟 tuning mysql 跟 php 效能 ">基本優化 tuning apache 跟 tuning mysql 跟 php 效能  (5)</a></li><li><a href="http://blog.wu-boy.com/2008/06/05/275/" title="[FreeBSD] 安裝 PHP APC 加速網頁速度">[FreeBSD] 安裝 PHP APC 加速網頁速度 (2)</a></li><li><a href="http://blog.wu-boy.com/2006/09/19/16/" title="FreeBSD + Lighttpd + php + mysql 安裝過程">FreeBSD + Lighttpd + php + mysql 安裝過程 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/06/07/2182/" title="[PHP] 好用 Debug PHP 工具 FirePHP for FireFox on CodeIgniter">[PHP] 好用 Debug PHP 工具 FirePHP for FireFox on CodeIgniter (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/26/2087/" title="Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)">Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf) (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/21/2054/" title="[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇)">[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇) (8)</a></li><li><a href="http://blog.wu-boy.com/2009/12/30/1920/" title="[PHP Framework] How to implement Plurk API in CodeIgniter">[PHP Framework] How to implement Plurk API in CodeIgniter (0)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2010/06/23/2240/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)</title>
		<link>http://blog.wu-boy.com/2010/03/26/2087/</link>
		<comments>http://blog.wu-boy.com/2010/03/26/2087/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 17:21:51 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_rpaf]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=2087</guid>
		<description><![CDATA[之前介紹 [FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇) 來當 Web 前端 Reverse Proxy，也有 load balance 的功能，不過碰到這樣的環境，後端 Apache Server 只會抓到 Reverse Proxy IP 來當作 log 紀錄，而無法正確取得 Client 端 IP，Varnish 官網 FAQ 有提到 log 檔案得的解決方法，不過在程式方面，要大量的修改，假設今天 Apache 跑10個 Virtual Host ，不就要去改10個網站程式，背後或許是一些大型 open source 的 Project，改起來相當不容易，也很費工夫。Darkhero 提供了 reverse proxy add forward module for Apache (mod_rpaf) 模組，只要裝上這模組，Apache 就不必動到其它設定就可以正確紀錄 log 檔案，且程式都不必修改，就可以得到正確 IP 了。
<span class="readmore"><a href="http://blog.wu-boy.com/2010/03/26/2087/" title="Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)" target="_blank">...詳全文（共740字）</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/appleboy/4462939520/" title="Flickr 上 appleboy46 的 feather"><img src="http://farm3.static.flickr.com/2705/4462939520_26be3f6fa9_o.gif" width="356" height="107" alt="feather" /></a><br />
之前介紹 <a href="http://blog.wu-boy.com/2010/03/21/2054/">[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇)</a> 來當 Web 前端 <a href="http://en.wikipedia.org/wiki/Reverse_proxy">Reverse Proxy</a>，也有 <a href="http://en.wikipedia.org/wiki/Load_balancing_(computing)">load balance</a> 的功能，不過碰到這樣的環境，後端 <a href="http://www.apache.org/">Apache</a> Server 只會抓到 Reverse Proxy IP 來當作 log 紀錄，而無法正確取得 Client 端 IP，<a href="http://varnish-cache.org/">Varnish</a> 官網 <a href="http://varnish-cache.org/wiki/FAQ">FAQ</a> 有提到 log 檔案得的解決方法，不過在程式方面，要大量的修改，假設今天 Apache 跑10個 <a href="http://httpd.apache.org/docs/2.0/vhosts/examples.html">Virtual Host</a> ，不就要去改10個網站程式，背後或許是一些大型 open source 的 Project，改起來相當不容易，也很費工夫。<a href="http://blog.darkhero.net/">Darkhero</a> 提供了 <a href="http://stderr.net/apache/rpaf/">reverse proxy add forward module for Apache (mod_rpaf)</a> 模組，只要裝上這模組，Apache 就不必動到其它設定就可以正確紀錄 log 檔案，且程式都不必修改，就可以得到正確 IP 了。</p>
<p>FreeBSD Ports 安裝方式：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> <span class="sy0">/</span>usr<span class="sy0">/</span>ports<span class="sy0">/</span>www<span class="sy0">/</span>mod_rpaf2<span class="sy0">/</span><br />
<span class="kw2">make</span> <span class="kw2">install</span> clean</div></div>
<p>修改 httpd.conf (FreeBSD: /usr/local/etc/apache22/httpd.conf)</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">LoadModule rpaf_module &nbsp; &nbsp; &nbsp; &nbsp;libexec<span class="sy0">/</span>apache22<span class="sy0">/</span>mod_rpaf.so</div></div>
<p>將上面 unmask，最後面加上：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">RPAFenable On<br />
RPAFsethostname On<br />
RPAFproxy_ips xxx.xxx.xxx.xxx 127.0.0.1<br />
RPAFheader X-Forwarded-For</div></div>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9">[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/21/2054/" title="[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇)">[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇) (8)</a></li><li><a href="http://blog.wu-boy.com/2008/09/13/388/" title="[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi">[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi (3)</a></li><li><a href="http://blog.wu-boy.com/2008/07/10/291/" title="[FreeBSD] Lighttpd + PHP + mod_proxy + FastCGI">[FreeBSD] Lighttpd + PHP + mod_proxy + FastCGI (1)</a></li><li><a href="http://blog.wu-boy.com/2008/07/01/286/" title="[FreeBSD]Apache 噴出 signal Segmentation fault (11)">[FreeBSD]Apache 噴出 signal Segmentation fault (11) (1)</a></li><li><a href="http://blog.wu-boy.com/2008/06/23/283/" title="[FreeBSD &#038; Linux]網站分流：簡易架設 HAProxy 伺服器">[FreeBSD &#038; Linux]網站分流：簡易架設 HAProxy 伺服器 (1)</a></li><li><a href="http://blog.wu-boy.com/2008/06/05/275/" title="[FreeBSD] 安裝 PHP APC 加速網頁速度">[FreeBSD] 安裝 PHP APC 加速網頁速度 (2)</a></li><li><a href="http://blog.wu-boy.com/2007/01/22/64/" title="[apache] mod cband 頻寬限制">[apache] mod cband 頻寬限制 (3)</a></li><li><a href="http://blog.wu-boy.com/2010/07/07/2276/" title="ProFTPD UseEncoding 繁體中文亂碼解決 Localization">ProFTPD UseEncoding 繁體中文亂碼解決 Localization (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros">[Vim] 想套用 *.php syntax 顏色於 *.ros (0)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2010/03/26/2087/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇)</title>
		<link>http://blog.wu-boy.com/2010/03/21/2054/</link>
		<comments>http://blog.wu-boy.com/2010/03/21/2054/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 16:12:44 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[www]]></category>
		<category><![CDATA[生活日記]]></category>
		<category><![CDATA[HAProxy]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=2054</guid>
		<description><![CDATA[在上禮拜跟 DarkHero 兄聊到 How To Build a Scalable Web Site (3/6) 的上課講義，互相討論了 MySQL Load balance 以及 http reverse proxy 的方式，以前自己有用 HAProxy 當作 Web 平衡負載，順便紀錄了 HAProxy FreeBSD 安裝方式，這次要來介紹今天重點：Varnish Cache Server，在近幾年流行的 Caching 機制，大家會想到 Squid，只要您設定良好的 Squid 參數，它一定運作的非常穩定，然而它的核心依然是 forward proxy，要架設成 Reverse Proxy 還必需要設定一些參數才可以達到，是有一定的困難性，然而 Varnish Cache Server 底層就是高效能 caching reverse proxy，也因為 Squid 是 1980 年發展出來的，程式架構過於老舊，可以參考 ArchitectNotes 瞭解這部份詳情。也許您會問到 Varnish 可以架設成  forward proxy 嗎？答案是可以的，但是您也許不會這麼做，因為它需要 DNS 技術，以及需要一個非常大且複雜的 Varnish VCL(Varnish Configuration Language) file。
<span class="readmore"><a href="http://blog.wu-boy.com/2010/03/21/2054/" title="[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇)" target="_blank">...詳全文（共3029字）</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/appleboy/4445679996/" title="Flickr 上 appleboy46 的 varnish-logo-red-64"><img src="http://farm3.static.flickr.com/2695/4445679996_0a9d597a94_o.gif" width="235" height="64" alt="varnish-logo-red-64" /></a><br />
在上禮拜跟 <a href="http://blog.darkhero.net">DarkHero</a> 兄聊到 <a href="http://blog.darkhero.net/?p=391">How To Build a Scalable Web Site (3/6)</a> 的上課講義，互相討論了 MySQL Load balance 以及 http <a href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a> 的方式，以前自己有用 <a href="http://haproxy.1wt.eu/">HAProxy</a> 當作 Web 平衡負載，順便紀錄了 <a href="http://blog.wu-boy.com/2008/06/23/283/">HAProxy FreeBSD 安裝方式</a>，這次要來介紹今天重點：<a href="http://varnish-cache.org/">Varnish Cache Server</a>，在近幾年流行的 Caching 機制，大家會想到 Squid，只要您設定良好的 Squid 參數，它一定運作的非常穩定，然而它的核心依然是 forward proxy，要架設成 Reverse Proxy 還必需要設定一些參數才可以達到，是有一定的困難性，然而 Varnish Cache Server 底層就是高效能 caching reverse proxy，也因為 Squid 是 1980 年發展出來的，程式架構過於老舊，可以參考 <a href="http://varnish-cache.org/wiki/ArchitectNotes">ArchitectNotes</a> 瞭解這部份詳情。也許您會問到 Varnish 可以架設成  forward proxy 嗎？答案是可以的，但是您也許不會這麼做，因為它需要 DNS 技術，以及需要一個非常大且複雜的 Varnish VCL(Varnish Configuration Language) file。</p>
<p>1. 今天要介紹如何在 FreeBSD 系統安裝，在介紹之前，系統必須先安裝好 apache，這樣才可以正確啟動，利用 ports 安裝：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> <span class="sy0">/</span>usr<span class="sy0">/</span>ports<span class="sy0">/</span>www<span class="sy0">/</span>varnish<span class="sy0">/</span><br />
<span class="kw2">make</span> <span class="kw2">install</span> clean</div></div>
<p>2. 修改 /etc/rc.conf</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0"># varnishd</span><br />
<span class="re2">varnishd_enable</span>=<span class="st0">&quot;YES&quot;</span><br />
<span class="re2">varnishd_listen</span>=<span class="st0">&quot;:80&quot;</span><br />
<span class="re2">varnishd_admin</span>=<span class="st0">&quot;:81&quot;</span><br />
<span class="re2">varnishd_backend</span>=<span class="st0">&quot;:5566&quot;</span><br />
<span class="re2">varnishd_config</span>=<span class="st0">&quot;/usr/local/etc/varnish/default.vcl&quot;</span></div></div>
<p>上面設定意思是說 Varnish listen on port 80，傳送 traffic 到後端 5566 port，管理連接埠是 81，也可以使用指令方式：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">varnishd <span class="re5">-a</span> :<span class="nu0">80</span> <span class="re5">-b</span> localhost:<span class="nu0">8080</span> <span class="re5">-T</span> localhost:<span class="nu0">6082</span></div></div>
<blockquote><p>Varnishd listen on port 80，and forwarding traffic to a web server listen on localhost port 8080. It also turns on the management interface on port 6082.</p></blockquote>
<p>3. 修改 default.vcl (Varnish Configuration Language)<br />
VCL 檔案告訴 Varnishd 正確的處理每個 request processing，包含在接受到 request 之前所處理的行為 vcl_recv()，另外還有 vcl_hit()、vcl_miss() 等&#8230;，都是用來處理 cache 如果存在或者是不存在時的情境 request。FreeBSD 預設放在 <span style="color:green">/usr/local/etc/varnish/default.vcl</span>。打開此檔案，您會看到：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">backend default <span class="br0">&#123;</span><br />
&nbsp; &nbsp;.host = <span class="st0">&quot;127.0.0.1&quot;</span>;<br />
&nbsp; &nbsp;.port = <span class="st0">&quot;80&quot;</span>;<br />
<span class="br0">&#125;</span></div></div>
<p>您只要把 host = &#8220;127.0.0.1&#8243; 改成你後端要連接的 ip 或者是 host，這樣 Varnish 會 forward traffic 到您的 web server。接下來只要啟動 apache 跟 Varnish 就算是初步架設完成。</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>etc<span class="sy0">/</span>rc.d<span class="sy0">/</span>apache22 restart<br />
<span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>etc<span class="sy0">/</span>rc.d<span class="sy0">/</span>varnishd restart</div></div>
<p><a href="http://www.flickr.com/photos/appleboy/4448204616/" title="Flickr 上 appleboy46 的 Varnish_01"><img src="http://farm3.static.flickr.com/2726/4448204616_8668e2d8b3.jpg" width="500" height="170" alt="Varnish_01" /></a><br />
大家可以看到 61.*.*.* 連到本機 80 port，接下來 Varnish 在開啟隨機 57475 port 連接到 Web Server 5566 port。</p>
<p><strong>Q:如何讓 apache 紀錄正確的 Client IP 到 log 檔案呢？</strong><br />
1. 打開 Vcl config 檔案，寫入<br />
Varnish configuration:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">sub vcl_recv <span class="br0">&#123;</span><br />
&nbsp; <span class="co0"># Add a unique header containing the client address</span><br />
&nbsp; remove req.http.X-Forwarded-For;<br />
&nbsp; <span class="kw1">set</span> &nbsp; &nbsp;req.http.X-Forwarded-For = client.ip;<br />
&nbsp; <span class="co0"># [...]</span><br />
<span class="br0">&#125;</span></div></div>
<p>2. 開啟 apache httpd.conf 加入此行：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">LogFormat <span class="st0">&quot;%{X-Forwarded-For}i %l %u %t <span class="es1">\&quot;</span>%r<span class="es1">\&quot;</span> %&gt;s %b <span class="es1">\&quot;</span>%{Referer}i<span class="es1">\&quot;</span> <span class="es1">\&quot;</span>%{User-Agent}i<span class="es1">\&quot;</span>&quot;</span> varnishcombined</div></div>
<p><a href="http://www.flickr.com/photos/appleboy/4448227216/" title="Flickr 上 appleboy46 的 Varnish_02"><img src="http://farm3.static.flickr.com/2694/4448227216_99663d5959.jpg" width="500" height="156" alt="Varnish_02" /></a></p>
<p><strong>Q:如何讓 PHP 程式紀錄正確的 Client IP？</strong><br />
可以參考底下程式碼就可以完全抓到 Proxy 後面真正使用者IP，否則您的 Web 只會抓到 Reverse Proxy 的 IP Address。</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">function</span> getIP<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>validip<span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_CLIENT_IP&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_CLIENT_IP&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">foreach</span><span class="br0">&#40;</span><a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;,&quot;</span><span class="sy0">,</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_X_FORWARDED_FOR&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$ip</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>validip<span class="br0">&#40;</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$ip</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="kw1">return</span> <span class="re0">$ip</span><span class="sy0">;</span><span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>validip<span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_X_FORWARDED&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_X_FORWARDED&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>validip<span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_FORWARDED_FOR&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_FORWARDED_FOR&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <br />
&nbsp; <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>validip<span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_FORWARDED&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_FORWARDED&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <br />
&nbsp; <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>validip<span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_X_FORWARDED&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;HTTP_X_FORWARDED&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <br />
&nbsp; <span class="kw1">else</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&quot;REMOTE_ADDR&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw2">function</span> validip<span class="br0">&#40;</span><span class="re0">$ip</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$ip</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <a href="http://www.php.net/ip2long"><span class="kw3">ip2long</span></a><span class="br0">&#40;</span><span class="re0">$ip</span><span class="br0">&#41;</span><span class="sy0">!=-</span><span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$reserved_ips</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'10.0.0.0'</span><span class="sy0">,</span><span class="st_h">'10.255.255.255'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'127.0.0.0'</span><span class="sy0">,</span><span class="st_h">'127.255.255.255'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'169.254.0.0'</span><span class="sy0">,</span><span class="st_h">'169.254.255.255'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'172.16.0.0'</span><span class="sy0">,</span><span class="st_h">'172.31.255.255'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'192.168.0.0'</span><span class="sy0">,</span><span class="st_h">'192.168.255.255'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re0">$reserved_ips</span> <span class="kw1">as</span> <span class="re0">$r</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$min</span> <span class="sy0">=</span> <a href="http://www.php.net/ip2long"><span class="kw3">ip2long</span></a><span class="br0">&#40;</span><span class="re0">$r</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$max</span> <span class="sy0">=</span> <a href="http://www.php.net/ip2long"><span class="kw3">ip2long</span></a><span class="br0">&#40;</span><span class="re0">$r</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><a href="http://www.php.net/ip2long"><span class="kw3">ip2long</span></a><span class="br0">&#40;</span><span class="re0">$ip</span><span class="br0">&#41;</span> <span class="sy0">&gt;=</span> <span class="re0">$min</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="br0">&#40;</span><a href="http://www.php.net/ip2long"><span class="kw3">ip2long</span></a><span class="br0">&#40;</span><span class="re0">$ip</span><span class="br0">&#41;</span> <span class="sy0">&lt;=</span> <span class="re0">$max</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span> <br />
&nbsp; <span class="kw1">else</span> <br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p><strong>Q:rotate Varnish log file every day？</strong><br />
打開 /etc/newsyslog.conf，加入底下兩行</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">/</span>var<span class="sy0">/</span>log<span class="sy0">/</span>varnish.log &nbsp; &nbsp; &nbsp; &nbsp;<span class="nu0">640</span> &nbsp; &nbsp; <span class="nu0">7</span> &nbsp; <span class="sy0">*</span> &nbsp; <span class="sy0">@</span>T00 &nbsp; &nbsp;JB &nbsp;<span class="sy0">/</span>var<span class="sy0">/</span>run<span class="sy0">/</span>varnishlog.pid<br />
<span class="sy0">/</span>var<span class="sy0">/</span>log<span class="sy0">/</span>varnishncsa.log &nbsp; &nbsp;<span class="nu0">640</span> &nbsp; &nbsp; <span class="nu0">7</span> &nbsp; <span class="sy0">*</span> &nbsp; <span class="sy0">@</span>T00 &nbsp; &nbsp;JB &nbsp;<span class="sy0">/</span>var<span class="sy0">/</span>run<span class="sy0">/</span>varnishncsa.pid</div></div>
<p>每天12點進行 log 備份，使用 gzip 壓縮 log 檔案。</p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9">[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/26/2087/" title="Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)">Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf) (0)</a></li><li><a href="http://blog.wu-boy.com/2008/09/13/388/" title="[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi">[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi (3)</a></li><li><a href="http://blog.wu-boy.com/2008/07/22/297/" title="[Linux] CentOS 5.1 安裝 Lighttpd + PHP5 + FastCgi + eaccelerator">[Linux] CentOS 5.1 安裝 Lighttpd + PHP5 + FastCgi + eaccelerator (3)</a></li><li><a href="http://blog.wu-boy.com/2008/07/10/293/" title="[轉貼] RoR：Ruby on Rails的部署方案選擇">[轉貼] RoR：Ruby on Rails的部署方案選擇 (0)</a></li><li><a href="http://blog.wu-boy.com/2008/07/03/287/" title="[FreeBSD]Lighttpd + php5 + 解決 wordpress Permalinks mod_write">[FreeBSD]Lighttpd + php5 + 解決 wordpress Permalinks mod_write (1)</a></li><li><a href="http://blog.wu-boy.com/2008/07/01/286/" title="[FreeBSD]Apache 噴出 signal Segmentation fault (11)">[FreeBSD]Apache 噴出 signal Segmentation fault (11) (1)</a></li><li><a href="http://blog.wu-boy.com/2008/06/23/283/" title="[FreeBSD &#038; Linux]網站分流：簡易架設 HAProxy 伺服器">[FreeBSD &#038; Linux]網站分流：簡易架設 HAProxy 伺服器 (1)</a></li><li><a href="http://blog.wu-boy.com/2008/06/18/281/" title="基本優化 tuning apache 跟 tuning mysql 跟 php 效能 ">基本優化 tuning apache 跟 tuning mysql 跟 php 效能  (5)</a></li><li><a href="http://blog.wu-boy.com/2008/06/05/275/" title="[FreeBSD] 安裝 PHP APC 加速網頁速度">[FreeBSD] 安裝 PHP APC 加速網頁速度 (2)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2010/03/21/2054/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[Vim] 想套用 *.php syntax 顏色於 *.ros</title>
		<link>http://blog.wu-boy.com/2010/03/16/2050/</link>
		<comments>http://blog.wu-boy.com/2010/03/16/2050/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 05:38:43 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=2050</guid>
		<description><![CDATA[Vim 是一套強大的編輯器，它分佈於各大 UNIX systems，安裝好一套 UNIX 系統，預設就是 Vi 編輯器(FreeBSD 預設是 ee)，相當好用，他也支援各種語言的 syntax，讓您在編輯檔案能夠看到各種不同顏色，在 FreeBSD 底下可以去看 /usr/local/share/vim/vim64/syntax/ 該資料夾支援各種語言，例如 PHP、Ruby、css、html、java、C/C++…等，假設今天我們想要 .ros 的副檔名需要用 php.vim syntax 來開啟，就必須做底下設定：
<span class="readmore"><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros" target="_blank">...詳全文（共548字）</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/appleboy/4436671479/" title="Flickr 上 appleboy46 的 vim_header"><img src="http://farm5.static.flickr.com/4018/4436671479_0596c469d4_o.gif" width="180" height="45" alt="vim_header" /></a><br />
<a href="http://www.vim.org/">Vim</a> 是一套強大的編輯器，它分佈於各大 UNIX systems，安裝好一套 UNIX 系統，預設就是 Vi 編輯器(<a href="http://www.freebsd.org">FreeBSD</a> 預設是 ee)，相當好用，他也支援各種語言的 syntax，讓您在編輯檔案能夠看到各種不同顏色，在 FreeBSD 底下可以去看 /usr/local/share/vim/vim64/syntax/ 該資料夾支援各種語言，例如 PHP、Ruby、css、html、java、C/C++…等，假設今天我們想要 .ros 的副檔名需要用 php.vim syntax 來開啟，就必須做底下設定：</p>
<p>執行底下：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">mkdri ~<span class="sy0">/</span>.vim<br />
<span class="kw2">vi</span> ~<span class="sy0">/</span>.vim<span class="sy0">/</span>filetype.vim</div></div>
<p>寫入 filetype.vim 資訊</p>
<div class="codecolorer-container vim " style="overflow:auto;white-space:nowrap;width:580px"><div class="vim codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span> version <span class="sy0">&lt;</span> <span class="nu0">600</span><br />
&nbsp; syntax clear<br />
<span class="kw1">elseif</span> <span class="kw3">exists</span><span class="br0">&#40;</span><span class="st0">&quot;b:current_syntax&quot;</span><span class="br0">&#41;</span><br />
&nbsp; finish<br />
<span class="kw1">endif</span><br />
augroup filetypedetect<br />
&nbsp; &nbsp; au<span class="sy0">!</span> BufRead,BufNewFile <span class="sy0">*.</span>ros setfiletype php<br />
augroup END</div></div>
<p>ps. on freebsd 7.1-RELEASE-p11 vim version 6.4.9</p>
<p>reference:<br />
<a href="http://fourdollars.blogspot.com/2009/05/vim-markdown-syntax.html">Vim 套用 Markdown syntax</a><br />
<a href="http://blog.longwin.com.tw/archives/000021.html">vi 設定</a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2009/12/12/1901/" title="[UNIX] Vim 命令圖解說明">[UNIX] Vim 命令圖解說明 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/11/2041/" title="[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項">[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/29/1918/" title="[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)">[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/06/11/1386/" title="[網站] 好站連結 (三)">[網站] 好站連結 (三) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/10/958/" title="Linux or FreeBSD screen 指令介紹使用">Linux or FreeBSD screen 指令介紹使用 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/09/948/" title="mydumper 取代 mysqldump 效能">mydumper 取代 mysqldump 效能 (1)</a></li><li><a href="http://blog.wu-boy.com/2009/03/07/940/" title=" Google App Engine SDK：python 基本教學安裝"> Google App Engine SDK：python 基本教學安裝 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/02/24/834/" title="如何在 console 端使用 Tail (View) Multiple Files on UNIX / Linux Console">如何在 console 端使用 Tail (View) Multiple Files on UNIX / Linux Console (3)</a></li><li><a href="http://blog.wu-boy.com/2009/02/23/829/" title="[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28">[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28 (2)</a></li><li><a href="http://blog.wu-boy.com/2009/01/13/712/" title="[Linux&#038;FreeBSD] Find 指令用法教學">[Linux&#038;FreeBSD] Find 指令用法教學 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2010/03/16/2050/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項</title>
		<link>http://blog.wu-boy.com/2010/03/11/2041/</link>
		<comments>http://blog.wu-boy.com/2010/03/11/2041/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 10:13:29 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[DenyHost]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=2041</guid>
		<description><![CDATA[DenyHosts 是一套用 Python 跟 shell script 寫出來的 open source base on Linux or FreeBSD (/var/log/secure on Redhat, /var/log/auth.log on Mandrake, FreeBSD, etc&#8230;)，用來阻擋 SSH Server 被攻擊，之前寫一篇 FreeBSD 安裝設定教學，有一點沒有注意到，就是打開 /etc/hosts.allow，注意要把 ALL : ALL : allow 放到最後一行，跟 iptables 設定原理是一樣的，會從第一條規則開始比對，如果比對成功，下面的 rule 就會略過比對了，參考英文說明：
<span class="readmore"><a href="http://blog.wu-boy.com/2010/03/11/2041/" title="[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項" target="_blank">...詳全文（共781字）</a></span>]]></description>
			<content:encoded><![CDATA[<p><a title="Flickr 上 appleboy46 的 denyhosts" href="http://www.flickr.com/photos/appleboy/4424616360/"><img src="http://farm5.static.flickr.com/4062/4424616360_8f2af7881e_o.png" alt="denyhosts" width="347" height="73" /></a><br />
<a href="http://denyhosts.sourceforge.net/">DenyHosts</a> 是一套用 <a href="http://www.python.org/">Python</a> 跟 shell script 寫出來的 open source base on Linux or FreeBSD (/var/log/secure on Redhat, /var/log/auth.log on Mandrake, FreeBSD, etc&#8230;)，用來阻擋 SSH Server 被攻擊，之前寫一篇 <a href="http://blog.wu-boy.com/2008/12/26/663/" alt="[FreeBSD]利用 DenyHosts 軟體擋掉暴力破解 ssh 的使用者">FreeBSD 安裝設定教學</a>，有一點沒有注意到，就是打開 /etc/hosts.allow，注意要把 ALL : ALL : allow 放到最後一行，跟 iptables 設定原理是一樣的，會從第一條規則開始比對，如果比對成功，下面的 rule 就會略過比對了，參考英文說明：</p>
<blockquote><p>Start by allowing everything (this prevents the rest of the file from working, so remove it when you need protection). The rules here work on a &#8220;First match wins&#8221; basis.</p></blockquote>
<p>/etc/hosts.deny 已經被 FreeBSD 棄用，所以必須把 allow 跟 deny 的 rule 都寫到 hosts.allow 檔案裡面才是正確的</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#</span><br />
<span class="co0"># DenyHosts file: /etc/hosts.deniedssh</span><br />
sshd : <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.deniedssh : deny<br />
sshd : ALL : allow<br />
<br />
<span class="co0"># Start by allowing everything (this prevents the rest of the file</span><br />
<span class="co0"># from working, so remove it when you need protection).</span><br />
<span class="co0"># The rules here work on a &quot;First match wins&quot; basis.</span><br />
<span class="co0"># move bottom by appleboy 2010.03.11</span><br />
ALL : ALL : allow</div></div>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2008/12/26/663/" title="[FreeBSD]利用 DenyHosts 軟體擋掉暴力破解 ssh 的使用者">[FreeBSD]利用 DenyHosts 軟體擋掉暴力破解 ssh 的使用者 (2)</a></li><li><a href="http://blog.wu-boy.com/2008/04/16/176/" title="[SSHFS] 好用的 SSH Filesystem fusefs-sshfs in FreeBSD or Linux">[SSHFS] 好用的 SSH Filesystem fusefs-sshfs in FreeBSD or Linux (0)</a></li><li><a href="http://blog.wu-boy.com/2008/03/19/155/" title="[筆記] ssh Tunnel 運用在 Linux and Windows FireFox">[筆記] ssh Tunnel 運用在 Linux and Windows FireFox (1)</a></li><li><a href="http://blog.wu-boy.com/2006/11/26/43/" title="[Linux,FreeBSD] scp 上傳跟下載">[Linux,FreeBSD] scp 上傳跟下載 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros">[Vim] 想套用 *.php syntax 顏色於 *.ros (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/29/1918/" title="[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)">[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/12/1901/" title="[UNIX] Vim 命令圖解說明">[UNIX] Vim 命令圖解說明 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/06/11/1386/" title="[網站] 好站連結 (三)">[網站] 好站連結 (三) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/10/958/" title="Linux or FreeBSD screen 指令介紹使用">Linux or FreeBSD screen 指令介紹使用 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/09/948/" title="mydumper 取代 mysqldump 效能">mydumper 取代 mysqldump 效能 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2010/03/11/2041/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[FreeBSD] Fanout and Fanterm Tool to run commands on multiple machines</title>
		<link>http://blog.wu-boy.com/2010/01/08/1950/</link>
		<comments>http://blog.wu-boy.com/2010/01/08/1950/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 07:44:10 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Fanout]]></category>
		<category><![CDATA[Fanterm]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=1950</guid>
		<description><![CDATA[在 Linux 或 FreeBSD 系統底下，如何下達 command 來達到多方控管機器，在網路上找到 Fanout and fanterm 這兩套軟體，可以實現我想要的目的，在 FreeBSD 有把 sysutils/fanout 進到 ports 裡面，安裝方式很簡單，就直接 make install clean 就可以了，用法也很簡易：
<span class="readmore"><a href="http://blog.wu-boy.com/2010/01/08/1950/" title="[FreeBSD] Fanout and Fanterm Tool to run commands on multiple machines" target="_blank">...詳全文（共1801字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>在 Linux 或 <a href="http://www.freebsd.org">FreeBSD</a> 系統底下，如何下達 command 來達到多方控管機器，在網路上找到 <a href="http://www.stearns.org/fanout/README.html#fanout">Fanout</a> and <a href="http://www.stearns.org/fanout/README.html#fanterm">fanterm</a> 這兩套軟體，可以實現我想要的目的，在 FreeBSD 有把 <a href="http://www.freshports.org/sysutils/fanout/">sysutils/fanout</a> 進到 ports 裡面，安裝方式很簡單，就直接 make install clean 就可以了，用法也很簡易：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">Usage:<br />
&nbsp; <span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>bin<span class="sy0">/</span>fanout <span class="st0">&quot;MACHINES&quot;</span> <span class="st0">&quot;commands and parameters to run on each machine&quot;</span><br />
&nbsp; <span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>bin<span class="sy0">/</span>fanout <span class="re5">-h</span> &nbsp; &nbsp; &nbsp;<span class="co0">#Show this help</span><br />
&nbsp; <span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>bin<span class="sy0">/</span>fanout <span class="re5">--noping</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="co0"># Do not ping before running command</span></div></div>
<p>當然事情沒有這麼簡單，因為是透過 SSH 方式去對其他機器下 command，所以作者都把預設 port 設定成 22，沒有完整考慮到其他環境，管理重要的 Server 怎麼會設定 22 阿，一定會改掉的阿，後來檢查一下 /usr/local/bin/fanout 這隻程式，並非編譯過的 binary 檔案，所以打開來看，就是利用 bash shell script 所寫的程式，網路上 Google 也找到一篇  <a href="http://www.linuxquestions.org/questions/linux-software-2/does-anyone-know-how-to-specify-a-ssh-port-number-with-fanout-776895/">Does anyone know how to specify a ssh port number with fanout?</a> 文章，但是最後我是自己把 bash 改成支援可調整 port，也就是 MACHINES 可以放入：ip:portt or hostname:port</p>
<p>patch 檔案：需要的就拿去 patch 就可以用了</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re5">---</span> <span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>bin<span class="sy0">/</span>fanout &nbsp; <span class="nu0">2010</span>-01-08 <span class="nu0">15</span>:06:<span class="nu0">47.000000000</span> +0800<br />
+++ fanout &nbsp;<span class="nu0">2010</span>-01-08 <span class="nu0">15</span>:00:<span class="nu0">04.000000000</span> +0800<br />
<span class="sy0">@@</span> -<span class="nu0">53</span>,<span class="nu0">13</span> +<span class="nu0">53</span>,<span class="nu0">22</span> <span class="sy0">@@</span><br />
&nbsp;<span class="re2">STARTTIME</span>=<span class="sy0">`</span><span class="kw2">date</span><span class="sy0">`</span><br />
&nbsp;<span class="kw1">for</span> ONETARGET <span class="kw1">in</span> <span class="re1">$TARGETS</span> ; <span class="kw1">do</span><br />
&nbsp; &nbsp; <span class="kw1">case</span> <span class="re1">$ONETARGET</span> <span class="kw1">in</span><br />
- &nbsp; <span class="sy0">*@*</span><span class="br0">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co0">#user@machine form</span><br />
+ &nbsp; <span class="sy0">*@*</span><span class="br0">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co0">#user@machine:port form</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">ONEUSER</span>=<span class="st0">&quot;-l <span class="es3">${ONETARGET%%@*}</span>&quot;</span><br />
- &nbsp; &nbsp; &nbsp; <span class="re2">ONEMACH</span>=<span class="co1">${ONETARGET##*@}</span><br />
- &nbsp; &nbsp; &nbsp; <span class="re2">HEADER</span>=<span class="st0">&quot;==== As <span class="es3">${ONETARGET%%@*}</span> on <span class="es2">$ONEMACH</span> ====&quot;</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="re2">SERVER</span>=<span class="co1">${ONETARGET##*@}</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="re2">HOST</span>=<span class="sy0">`</span><span class="kw3">echo</span> <span class="re1">$SERVER</span> <span class="sy0">|</span> <span class="kw2">awk</span> -F: <span class="st_h">'{ printf $1 }'</span><span class="sy0">`</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="re2">PORT</span>=<span class="sy0">`</span><span class="kw3">echo</span> <span class="re1">$SERVER</span> <span class="sy0">|</span> <span class="kw2">awk</span> -F: <span class="st_h">'{ printf $2 }'</span><span class="sy0">`</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es2">$PORT</span>&quot;</span> <span class="sy0">!</span>= <span class="st0">&quot;&quot;</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">ONEPORT</span>=<span class="st0">&quot;-p <span class="es3">${PORT}</span>&quot;</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="kw1">else</span><br />
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">ONEPORT</span>=<span class="st0">&quot;&quot;</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="kw1">fi</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="re2">ONEMACH</span>=<span class="co1">${HOST}</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="re2">HEADER</span>=<span class="st0">&quot;==== As <span class="es3">${ONEUSER}</span> on <span class="es2">$ONEMACH</span> port: <span class="es3">${PORT}</span>====&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">;;</span><br />
&nbsp; &nbsp; <span class="sy0">*</span><span class="br0">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co0">#just machine form</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">ONEUSER</span>=<span class="st0">&quot;&quot;</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="re2">ONEPORT</span>=<span class="st0">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">ONEMACH</span>=<span class="re1">$ONETARGET</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">HEADER</span>=<span class="st0">&quot;==== On <span class="es2">$ONEMACH</span> ====&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">;;</span><br />
<span class="sy0">@@</span> -<span class="nu0">74</span>,<span class="nu0">7</span> +<span class="nu0">83</span>,<span class="nu0">7</span> <span class="sy0">@@</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es2">$PING</span>&quot;</span> = <span class="st0">&quot;NO&quot;</span> <span class="br0">&#93;</span> <span class="sy0">||</span> <span class="kw2">ping</span> <span class="re5">-c</span> <span class="nu0">3</span> <span class="re1">$ONEMACH</span> <span class="sy0">&gt;/</span>dev<span class="sy0">/</span>null <span class="nu0">2</span><span class="sy0">&gt;/</span>dev<span class="sy0">/</span>null ; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> Starting <span class="re1">$ONETARGET</span> <span class="sy0">&gt;/</span>dev<span class="sy0">/</span>stderr &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co0">#Machine is reachable</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co0">#Show machine name header, show command output, indented two spaces, save all to a temp file.</span><br />
- &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span> <span class="kw3">echo</span> <span class="re1">$HEADER</span> ; <span class="kw2">ssh</span> <span class="re5">-n</span> <span class="re1">$ONEUSER</span> <span class="re1">$ONEMACH</span> <span class="st0">&quot;$*&quot;</span> <span class="sy0">|</span> <span class="kw2">sed</span> <span class="re5">-e</span> <span class="st_h">'s/^/ &nbsp;/'</span> ; <span class="kw3">echo</span> <span class="br0">&#41;</span> <span class="sy0">&gt;</span><span class="re1">$TMPFILE</span> <span class="sy0">&amp;</span><br />
+ &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span> <span class="kw3">echo</span> <span class="re1">$HEADER</span> ; <span class="kw2">ssh</span> <span class="re1">$ONEPORT</span> <span class="re5">-n</span> <span class="re1">$ONEUSER</span> <span class="re1">$ONEMACH</span> <span class="st0">&quot;$*&quot;</span> <span class="sy0">|</span> <span class="kw2">sed</span> <span class="re5">-e</span> <span class="st_h">'s/^/ &nbsp;/'</span> ; <span class="kw3">echo</span> <span class="br0">&#41;</span> <span class="sy0">&gt;</span><span class="re1">$TMPFILE</span> <span class="sy0">&amp;</span><br />
&nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> <span class="re1">$ONETARGET</span> unavailable <span class="sy0">&gt;/</span>dev<span class="sy0">/</span>stderr &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co0">#Machine not responding</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> <span class="re1">$HEADER</span> ; <span class="kw3">echo</span> <span class="st0">&quot;==== Machine unreachable by ping&quot;</span> ; <span class="kw3">echo</span> <span class="sy0">&gt;</span><span class="re1">$TMPFILE</span></div></div>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/07/07/2276/" title="ProFTPD UseEncoding 繁體中文亂碼解決 Localization">ProFTPD UseEncoding 繁體中文亂碼解決 Localization (0)</a></li><li><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9">[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/26/2087/" title="Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)">Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf) (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros">[Vim] 想套用 *.php syntax 顏色於 *.ros (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/11/2041/" title="[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項">[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/29/1918/" title="[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)">[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/12/1901/" title="[UNIX] Vim 命令圖解說明">[UNIX] Vim 命令圖解說明 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/10/1894/" title="[FreeBSD] freebsd kernel: fxp0: link state changed to DOWN / UP">[FreeBSD] freebsd kernel: fxp0: link state changed to DOWN / UP (0)</a></li><li><a href="http://blog.wu-boy.com/2009/11/18/1843/" title="[FreeBSD] port committer 快速建立 pkg-plist">[FreeBSD] port committer 快速建立 pkg-plist (1)</a></li><li><a href="http://blog.wu-boy.com/2009/11/03/1781/" title="[Perl&#038;PHP] time() and Class::Date 日期轉換運算">[Perl&#038;PHP] time() and Class::Date 日期轉換運算 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2010/01/08/1950/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)</title>
		<link>http://blog.wu-boy.com/2009/12/29/1918/</link>
		<comments>http://blog.wu-boy.com/2009/12/29/1918/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 12:59:40 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=1918</guid>
		<description><![CDATA[今天在 commit 程式碼到 github 網站，不小心把 Plurk 帳號密碼給 commit 上去，發生這種事情，所以趕快上網查了一下如何移除 commit 歷史紀錄：
假設我們的 commit tree 如下：
<span class="readmore"><a href="http://blog.wu-boy.com/2009/12/29/1918/" title="[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)" target="_blank">...詳全文（共726字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>今天在 commit 程式碼到 <a href="http://github.com/">github</a> 網站，不小心把 Plurk 帳號密碼給 commit 上去，發生這種事情，所以趕快上網查了一下如何移除 commit 歷史紀錄：</p>
<p>假設我們的 commit tree 如下：</p>
<blockquote><p>R&#8211;A&#8211;B&#8211;C&#8211;D&#8211;E&#8211;HEAD</p></blockquote>
<p>接下來要移除 B 跟 C 的 commit tree，變成</p>
<blockquote><p>R&#8211;A&#8211;D&#8217;&#8211;E&#8211;HEAD</p></blockquote>
<p>有兩種方式可以移除 B &#038; C</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0"># detach head and move to D commit</span><br />
git checkout <span class="sy0">&lt;</span>SHA1-for-D<span class="sy0">&gt;</span><br />
<br />
<span class="co0"># move HEAD to A, but leave the index and working tree as for D</span><br />
git reset <span class="re5">--soft</span> <span class="sy0">&lt;</span>SHA1-for-A<span class="sy0">&gt;</span><br />
<br />
<span class="co0"># Redo the D commit re-using the commit message, but now on top of A</span><br />
git commit <span class="re5">-C</span> <span class="sy0">&lt;</span>SHA1-for-D<span class="sy0">&gt;</span><br />
<br />
<span class="co0"># Re-apply everything from the old D onwards onto this new place </span><br />
git rebase <span class="re5">--onto</span> HEAD <span class="sy0">&lt;</span>SHA1-for-D<span class="sy0">&gt;</span> master<br />
<br />
<span class="co0"># push it</span><br />
git push <span class="re5">--force</span></div></div>
<p>另一種方法是利用 cherry-pick 方式</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">git rebase <span class="re5">--hard</span> <span class="sy0">&lt;</span>SHA1 of A<span class="sy0">&gt;</span><br />
git cherry-pick <span class="sy0">&lt;</span>SHA1 of D<span class="sy0">&gt;</span><br />
git cherry-pick <span class="sy0">&lt;</span>SHA1 of E<span class="sy0">&gt;</span></div></div>
<p>這會直接忽略 B 跟 C 的 history，詳細資料可以查詢 git help cherry-pick 或者是 git help rebase</p>
<p>參考：<br />
<a href="http://stackoverflow.com/questions/495345/git-removing-selected-commits-from-repository">Git: removing selected commits from repository</a><br />
<a href="http://bogdan.org.ua/2009/02/13/git-how-to-remove-file-commit-from-history.html">Git: how to remove file and commit from history</a><br />
<a href="http://kerneltrap.org/mailarchive/git/2007/11/18/425729">Re: ! [rejected] master -> master (non-fast forward)</a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros">[Vim] 想套用 *.php syntax 顏色於 *.ros (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/11/2041/" title="[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項">[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/12/1901/" title="[UNIX] Vim 命令圖解說明">[UNIX] Vim 命令圖解說明 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/10/05/1701/" title="[FreeBSD] 簡易架設 git Server，git 使用教學">[FreeBSD] 簡易架設 git Server，git 使用教學 (1)</a></li><li><a href="http://blog.wu-boy.com/2009/06/11/1386/" title="[網站] 好站連結 (三)">[網站] 好站連結 (三) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/10/958/" title="Linux or FreeBSD screen 指令介紹使用">Linux or FreeBSD screen 指令介紹使用 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/09/948/" title="mydumper 取代 mysqldump 效能">mydumper 取代 mysqldump 效能 (1)</a></li><li><a href="http://blog.wu-boy.com/2009/03/07/940/" title=" Google App Engine SDK：python 基本教學安裝"> Google App Engine SDK：python 基本教學安裝 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/02/24/834/" title="如何在 console 端使用 Tail (View) Multiple Files on UNIX / Linux Console">如何在 console 端使用 Tail (View) Multiple Files on UNIX / Linux Console (3)</a></li><li><a href="http://blog.wu-boy.com/2009/02/23/829/" title="[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28">[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28 (2)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2009/12/29/1918/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[UNIX] Vim 命令圖解說明</title>
		<link>http://blog.wu-boy.com/2009/12/12/1901/</link>
		<comments>http://blog.wu-boy.com/2009/12/12/1901/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 11:04:27 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=1901</guid>
		<description><![CDATA[Vim 是一套在 Windows 或者是 UNIX 系統上面非常強大的編輯器，在 vgod’s blog 看到一篇：『給程式設計師的Vim入門圖解說明』，原作者提供了 pdf 以及 png 檔案讓大家下載阿，相當方便，看到這篇就馬上印出來貼在自己的桌子前面，圖解內容也相當清楚，很適合剛學習 UNIX 系統所需要的一些基本 Vim 指令，如何分割視窗，刪除行…等，另外在 Tsung&#8217;s Blog 看到 好文: Vim 食譜(CookBook、Recipes)，提供了兩個好用連結：
<span class="readmore"><a href="http://blog.wu-boy.com/2009/12/12/1901/" title="[UNIX] Vim 命令圖解說明" target="_blank">...詳全文（共344字）</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vim.org/">Vim</a> 是一套在 Windows 或者是 UNIX 系統上面非常強大的編輯器，在 <a href="http://blog.vgod.tw/">vgod’s blog</a> 看到一篇：『<a href="http://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/">給程式設計師的Vim入門圖解說明</a>』，原作者提供了 <a href="http://blog.vgod.tw/go.php?http://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.pdf">pdf</a> 以及 <a href="http://blog.vgod.tw/go.php?http://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.png">png</a> 檔案讓大家下載阿，相當方便，看到這篇就馬上印出來貼在自己的桌子前面，圖解內容也相當清楚，很適合剛學習 UNIX 系統所需要的一些基本 Vim 指令，如何分割視窗，刪除行…等，另外在 <a href="http://plog.longwin.com.tw">Tsung&#8217;s Blog</a> 看到 好文: <a href="http://plog.longwin.com.tw/document-ebook/2009/12/03/vim-recipes-cookbook-ebook-2009">Vim 食譜(CookBook、Recipes)</a>，提供了兩個好用連結：</p>
<ul>
<li><a  href="http://vim.runpaint.org/" target="_blank">Vim Recipes</a> &#8211; Vim 由淺入深, 每篇都很短, 非常推薦此書~ (可線上看, 也可免費下載)</li>
<li><a title="Vim Cookbook" href="http://www.oualline.com/vim-cook.html" target="_blank">Vim Cookbook</a> &#8211; Vim 食譜, 這篇專門紀錄常用、好用的密技.</li>
</ul>
<p>都可以參考看看喔，對於學習 <a href="http://www.vim.org/">Vim</a> 會有相當大的幫助，底下兩張是從 <a href="http://blog.vgod.tw/">vgod’s blog</a> 轉錄過來的。<br />
<a title="Flickr 上 appleboy46 的 vim-cheat-sheet-full" href="http://www.flickr.com/photos/appleboy/4178373148/"><img src="http://farm3.static.flickr.com/2598/4178373148_b39a3131ff.jpg" alt="vim-cheat-sheet-full" width="500" height="294" /></a><br />
<a href="http://www.flickr.com/photos/appleboy/4177612069/" title="Flickr 上 appleboy46 的 vim-cheat-sheet-diagram"><img src="http://farm3.static.flickr.com/2511/4177612069_bcb9ebc3f7.jpg" width="500" height="438" alt="vim-cheat-sheet-diagram" /></a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros">[Vim] 想套用 *.php syntax 顏色於 *.ros (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/11/2041/" title="[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項">[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/29/1918/" title="[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)">[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/06/11/1386/" title="[網站] 好站連結 (三)">[網站] 好站連結 (三) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/10/958/" title="Linux or FreeBSD screen 指令介紹使用">Linux or FreeBSD screen 指令介紹使用 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/09/948/" title="mydumper 取代 mysqldump 效能">mydumper 取代 mysqldump 效能 (1)</a></li><li><a href="http://blog.wu-boy.com/2009/03/07/940/" title=" Google App Engine SDK：python 基本教學安裝"> Google App Engine SDK：python 基本教學安裝 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/02/24/834/" title="如何在 console 端使用 Tail (View) Multiple Files on UNIX / Linux Console">如何在 console 端使用 Tail (View) Multiple Files on UNIX / Linux Console (3)</a></li><li><a href="http://blog.wu-boy.com/2009/02/23/829/" title="[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28">[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28 (2)</a></li><li><a href="http://blog.wu-boy.com/2009/01/13/712/" title="[Linux&#038;FreeBSD] Find 指令用法教學">[Linux&#038;FreeBSD] Find 指令用法教學 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2009/12/12/1901/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[FreeBSD] freebsd kernel: fxp0: link state changed to DOWN / UP</title>
		<link>http://blog.wu-boy.com/2009/12/10/1894/</link>
		<comments>http://blog.wu-boy.com/2009/12/10/1894/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 03:00:15 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=1894</guid>
		<description><![CDATA[這一個禮拜被機器弄的頭昏腦脹，突然網路斷掉，然後不知不覺中又好了，接下來是斷斷續續，時好時壞，所以去檢查看一下 /var/log/message 訊息，log 檔案吐出很多底下的資訊：
Dec  9 21:17:02 freebsd kernel: fxp0: link state changed to DOWN
<span class="readmore"><a href="http://blog.wu-boy.com/2009/12/10/1894/" title="[FreeBSD] freebsd kernel: fxp0: link state changed to DOWN / UP" target="_blank">...詳全文（共917字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>這一個禮拜被機器弄的頭昏腦脹，突然網路斷掉，然後不知不覺中又好了，接下來是斷斷續續，時好時壞，所以去檢查看一下 /var/log/message 訊息，log 檔案吐出很多底下的資訊：</p>
<blockquote><p>Dec  9 21:17:02 freebsd kernel: fxp0: link state changed to DOWN<br />
Dec  9 21:17:03 freebsd kernel: fxp0: link state changed to UP<br />
Dec  9 21:17:10 freebsd kernel: fxp0: link state changed to DOWN<br />
Dec  9 21:17:12 freebsd kernel: fxp0: link state changed to UP</p></blockquote>
<p>在網路上 <a href="http://www.freebsd.org">FreeBSD</a> mail list 查到一篇：『<a href="http://lists.freebsd.org/pipermail/freebsd-net/2007-September/015237.html">Interface Status changes to UP and Down</a>』，裡面提到通常是硬體的問題，換過 switch 以及網路線，測試還是有問題，網路會斷斷續續，後來就用主機板上面另外兩個網孔測試，網路就不會時好時壞了，由於時常更改 /etc/rc.conf 裡面的 ip 設定，要重新啟動網路卡介面，這樣會造成遠端 ssh 斷線，解決方式請用下面指令：</p>
<p><strong>How do I restart network service over ssh session?</strong></p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">/</span>etc<span class="sy0">/</span>rc.d<span class="sy0">/</span>netif restart <span class="sy0">&amp;&amp;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>rc.d<span class="sy0">/</span>routing restart</div></div>
<p>底下一些常用 FreeBSD 網路指令：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#關閉網卡</span><br />
<span class="kw2">ifconfig</span> network-interface down<br />
<span class="co0">#啟動網卡</span><br />
<span class="kw2">ifconfig</span> network-interface up<br />
<span class="co0">#觀看尚未啟動的網卡</span><br />
<span class="kw2">ifconfig</span> <span class="re5">-d</span><br />
<span class="co0">#觀看已啟動網卡</span><br />
<span class="kw2">ifconfig</span> <span class="re5">-u</span><br />
<span class="co0"># FreeBSD Update / restart routing tables / service</span><br />
<span class="sy0">/</span>etc<span class="sy0">/</span>rc.d<span class="sy0">/</span>routing restart</div></div>
<p>Reference<br />
<a href="http://www.cyberciti.biz/tips/freebsd-how-to-start-restart-stop-network-service.html">FreeBSD: How To Start / Restart / Stop Network and Routing Service</a><br />
<a href="http://www.cyberciti.biz/tips/freebsd-how-to-setup-2-ip-address-on-one-nic.html">FreeBSD IP Alias: Setup 2 or More IP address on One NIC</a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/07/07/2276/" title="ProFTPD UseEncoding 繁體中文亂碼解決 Localization">ProFTPD UseEncoding 繁體中文亂碼解決 Localization (0)</a></li><li><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9">[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/26/2087/" title="Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)">Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf) (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/16/2050/" title="[Vim] 想套用 *.php syntax 顏色於 *.ros">[Vim] 想套用 *.php syntax 顏色於 *.ros (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/11/2041/" title="[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項">[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/01/08/1950/" title="[FreeBSD] Fanout and Fanterm Tool to run commands on multiple machines">[FreeBSD] Fanout and Fanterm Tool to run commands on multiple machines (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/29/1918/" title="[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄)">[Git] how to remove file and commit from history(如何移除 commit 歷史紀錄) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/12/1901/" title="[UNIX] Vim 命令圖解說明">[UNIX] Vim 命令圖解說明 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/11/18/1843/" title="[FreeBSD] port committer 快速建立 pkg-plist">[FreeBSD] port committer 快速建立 pkg-plist (1)</a></li><li><a href="http://blog.wu-boy.com/2009/11/03/1781/" title="[Perl&#038;PHP] time() and Class::Date 日期轉換運算">[Perl&#038;PHP] time() and Class::Date 日期轉換運算 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2009/12/10/1894/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
