<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.11" -->
<rss version="0.92">
<channel>
	<title>Real-Blog</title>
	<link>http://www.real-blog.com</link>
	<description>關於 PHP, Linux, Open Source 及個人生活記載的網誌。</description>
	<lastBuildDate>Thu, 30 Apr 2009 07:53:03 +0000</lastBuildDate>
	<docs>http://backend.userland.com/rss092</docs>
	<language>en</language>
	
	<item>
		<title>PHPExcel 及 PHPPowerPoint</title>
		<description>在網上找到兩個實用的 php class，分別是 PHPExcel 及 PHPPowerPoint。它們分別可以很簡單地透過 PHP 讀取及寫入 Excel 2007 及 PowerPoint 2007 的檔案。  </description>
		<link>http://www.real-blog.com/programming/541</link>
			</item>
	<item>
		<title>影婚紗相</title>
		<description>剛過去的星期三去了影婚紗相，由早上 8:00 到婚紗攝影公司化妝、set 頭及換衫 (這段時間我主要是等)，一直到晚上 8:00 才回去落妝。

我開始時已經知道影足一日相會很累，也實際是比我預期更累，而裡面只有從一個景點到另一個景點途中可以休息一下，午飯及晚飯也在車上食飽算數。雖然過程時辛苦，但看到女朋友化好妝，穿起婚紗及晚裝真的很漂亮，這就覺得一切也值得了。下星期可以睇相，希望出來的效果會好看。 </description>
		<link>http://www.real-blog.com/my-life/540</link>
			</item>
	<item>
		<title>修改 IIS 上傳限制</title>
		<description>IIS 預設上傳限制為 200kb，要修改這個限制，方法如下：

1. 開啟 Internet Information Services Manager (IIS)。 (中文版好像叫 IIS 管理員)

2. 在 server 上面 right click 及選擇 Properties

3. 選取 &#34;Enable Direct Metabase Edit&#34; 並按 OK

4. 開啟 Notepad，開啟以下檔案

%Windows dir%\System 32\Inetsrv\MetaBase.xml

5. 找出字串 AspMaxRequestEntityAllowed，預設是 204800，即 200kb，例如想改為 5mb 的話，應改為：

預設為 AspMaxRequestEntityAllowed = &#34;52428800&#34;

6. 完成後儲存 MetaBase.xml 便完成，不須要重新啟動 IIS。

7. 回到 Internet Information Services Manager (IIS)，移除 &#34;Enable ...</description>
		<link>http://www.real-blog.com/programming/539</link>
			</item>
	<item>
		<title>編寫只給特定用戶執行的 shell script</title>
		<description>在編寫了一些 shell script 並打算只給予特定用戶執行，可以先取得用戶的 user id，或者直接用 whoami 指令檢查使用者名稱，例如：


if [ $(whoami) = &#34;samtang&#34; ]
then
 &#160;&#160; # 執行程式碼
else
 &#160;&#160; echo &#34;You cannot run this script.&#34;
 &#160;&#160; exit 0
fi


如果在另一個情況下，不容許特定用戶執行，可以這樣寫：

if [ $(whoami) = &#34;root&#34; ]
then
 &#160;&#160; echo &#34;You cannot run this script.&#34;
 &#160;&#160; exit 1
fi
 </description>
		<link>http://www.real-blog.com/linux-bsd-notes/538</link>
			</item>
	<item>
		<title>Sylpheed 電郵軟件</title>
		<description>Sylpheed 是一個建基於 GTK+ 的開源電郵軟件，支援 Windows 及 Unix Like 環境，特別之處是耗用系統資源十分少，及執行起來十分快速。雖然佔用資料少，但功能可是十分豐富。

以前使用 Becky! Internet Mail 已經有好幾年，也十分滿意它的效能，可是 Becky! 不支援 Windows 以外的作業系統，自從幾個月前轉用 Ubuntu 後便沒有用了。剛開始用 Ubuntu 時，用過 Evolution 及 Thunderbird，可是就是不喜歡它們的執行速度，一直也覺得不順手。

上星期找到 Sylpheed 這款電郵軟件，用了一個星期後覺得很有 Becky! 的味道，操作完全沒有不習慣的感覺，執行速度快速，尤其是搜索功能覺得比 Becky! 更快。如果是像我一樣著重電郵軟件的速度，而且郵箱內的郵件數目很多，那麼 Sylpheed 是一個很好的選擇。

至於將箱件從 Thunderbird 匯入 Sylpheed 也很簡單，以下是在 Ubuntu 的安裝及匯入方法：

1. 在終端機上面，轉到以下目錄:

cd ~/.mozilla-thunderbird/*.default/Mail/Local\ Folders

裡面會有 Thunderbird 的郵件目錄檔案，將要匯入的目錄檔案複製到家目錄，例如:

cp Inbox ~/

2. 輸入以下指令透過 apt-get 安裝 Sylpheed:

sudo apt-get ...</description>
		<link>http://www.real-blog.com/software/537</link>
			</item>
	<item>
		<title>Apache 防止 DDoS 攻擊</title>
		<description>DDoS (distributed denial-of-service) 及 DoS (denial-of-service) 在網路上十分常見，而 DoS 攻擊所傳送的請求跟正常的請求一樣，分別在於每秒鐘發出大量請求到伺服器，使伺服器的負載增加，最常見的情況是伺服器暫停服務。

而 mod_evasive 則是一個預防 Apache 遭受 DDos 攻擊的模組，可以防止同一個 IP 對相同 URI 發出的大量請求，可設定的選項有：

-- 限制同一個 IP 在一定秒數內請求一個頁面或檔案的次數。
-- 限制同一個 IP 一秒內只可發出 50 個請求。
-- 設定被禁止的 IP 封鎖時間。

以下是 mod_evasive 的安裝方法：

1. 先將原來的 httpd.conf 備份起來。

2. 到 http://www.zdziarski.com/projects/mod_evasive/ 下載 mod_evasive。

3. 在指令模式解壓及編譯 mod_evasive：


tar zxvf mod_evasive_1.10.1.tar.gz
cd mod_evasive/
apxs -cia mod_evasive20.c


以上的 apxs 會放在 Apache 的 ...</description>
		<link>http://www.real-blog.com/linux-bsd-notes/536</link>
			</item>
	<item>
		<title>提高 Apache 的 MaxClients 選項</title>
		<description>如果碰到網頁伺服器突然變慢，然後網頁服務停止，在 apache 的 error log 找到以下語句：

[error] server reached MaxClients setting, consider raising the MaxClients setting

那麼就是 Apache 超過最大連線數，如果是 Apache 2.0 的話便不用重新編譯，只要開啟 httpd.conf 修改 MaxClients 選項。


StartServers 10
MinSpareServers 10
MaxSpareServers 15
MaxClients 200
MaxRequestsPerChild 10000


完成後重新啟動 Apache 即可。 </description>
		<link>http://www.real-blog.com/linux-bsd-notes/535</link>
			</item>
	<item>
		<title>用 PHP 查詢 MySQL Table 使用空間</title>
		<description>要查詢 MySQL 資料表所用的空間，雖然資料表是用 MyISAM 的話，可以直接用 ls 指令知道，但這個方法不可以用在 InnoDB 資料表上面。

要計算資料表的容量，可以供用 MySQL 語句 &#34;SHOW TABLE STATUS&#34; 實現，然後將回傳的 Data_length 加 Index_length 即可。以下程式會擷取資料庫內所有資料表的使用空間：
[PHP]
 </description>
		<link>http://www.real-blog.com/programming/534</link>
			</item>
	<item>
		<title>Ubuntu 安裝 terminus 及 Fixedsys 字型</title>
		<description>平日使用電腦習慣在終端機及寫程式時使用 terminus 字型，而以 plain 閱讀電郵則喜歡 Fixedsys 字型。但 Ubuntu 安裝也這兩種字型也沒有，以下是安裝以上兩種字型的方法：

安裝 terminus
在終端機打入以下指令即可：

sudo apt-get install xfonts-terminus

安裝 Fixedsys
到 fixedsys 下載 fixedsys 的 ttf 檔，解壓後將 Fixedsys500c.ttf 複製到 /usr/share/fonts/truetype/，指令如下：

sudo cp /path/Fixedsys500c.ttf /usr/share/fonts/truetype/
sudo fc-cache -f -v 

這樣就可以使用 terminus 及 Fixedsys 字型 了。 </description>
		<link>http://www.real-blog.com/linux-bsd-notes/533</link>
			</item>
	<item>
		<title>Linux Memory Management</title>
		<description>好文推介，介紹 Linux 的記憶體管理：

Memory management is the heart of operating systems; it is crucial for both programming and system administration. In the next few posts I’ll cover memory with an eye towards practical aspects, but without shying away from internals. While the concepts are generic, examples are mostly from Linux and ...</description>
		<link>http://www.real-blog.com/linux-bsd-notes/532</link>
			</item>
	<item>
		<title>重新設定 MySQL root 密碼</title>
		<description>如果忘記了 MySQL 的 root 密碼，可以透過以下方法重新設定：

1. 停止 MySQL server。

# /etc/init.d/mysql stop

2. 啟動 MySQL server，並加上 --skip-grant-tables 參數，便可以略過輸入密碼的過程:

# mysqld_safe --skip-grant-tables &

3. 用 root 連接到 MySQL server，輸入:

mysql -u root

4. 進入 MySQL server 後，輸入以下幾行 SQL 語句:
mysql&#62; use mysql;
mysql&#62; update user set password=PASSWORD(&#34;newpass&#34;) where User='root';
mysql&#62; flush privileges;
mysql&#62; quit

5. 重新啟動 MySQL 即可。

 </description>
		<link>http://www.real-blog.com/linux-bsd-notes/531</link>
			</item>
	<item>
		<title>&#8220;==&#8221; 及 &#8220;===&#8221; 在 PHP 的分別</title>
		<description>在 PHP 裡面，兩個比較運算式 &#34;==&#34; 及 &#34;===&#34; 的分別是，&#34;==&#34; 用作檢查變數的值是否相同；而 &#34;==&#34; 則會檢查變數的值及資料型態。

&#34;==&#34;:
[PHP][/PHP]

以上程式碼執行結果會輸入 &#34;Yes&#34;，因為變數 $str_var 及整數 123 是相同的值，但如果改用 &#34;===&#34; 便會有不同的結果：

&#34;===&#34;
[PHP][/PHP]

以上程式碼會輸入 &#34;No&#34;，因為雖然 $str_var 及 123 的值是相同，但兩者的資料型態不同。 (用引號包著的 &#34;123&#34; 是字串；而沒有引號的 123 則是整數)

但如果將程式碼改成以下這樣，便會輸出 &#34;Yes&#34;
[PHP][/PHP] </description>
		<link>http://www.real-blog.com/programming/530</link>
			</item>
	<item>
		<title>透過 Linux 恢復 Windows 系統管理員密碼</title>
		<description>如果忘記了 Windows 的 administrator 密碼，可以透過 Linux 的 Live CD 進行恢復，而這裡會使用 Ubuntu 作為例子：

1. 使用 Ubuntu Live CD 開機

2. 安裝一個名為 "chntpw" 的程式

$ sudo apt-get install chntpw

3. 安裝 "chntpw" 後，便要將 Windows 的 NTFS 分割區掛載。

4. 進入 Windows 分割區下的 system32/config 目錄，然後輸入：

$ sudo chntpw SAM

5. 出現了一堆訊息後，系統會提示 reset 密碼，如果想設成空密碼，可以輸入星號 *，重新開機後便可以進入 Windows。
 </description>
		<link>http://www.real-blog.com/linux-bsd-notes/529</link>
			</item>
	<item>
		<title>Ubuntu 8.10 安裝 Java</title>
		<description>安裝 Ubuntu 後系統預設沒有安裝 Java，以下是安裝方法：

$ sudo apt-get install sun-java6-jre sun-java6-plugin

安裝後再設定 Firefox 成支援 java
$ sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.10/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox/plugins/ </description>
		<link>http://www.real-blog.com/linux-bsd-notes/528</link>
			</item>
	<item>
		<title>只針對檔案或目錄 chmod</title>
		<description>在 Unix Like 環境可以用 chmod 改變檔案或目錄的權限，以下方法可以只針對檔案或目錄 chmod：

1. 在當前目錄下遁迴 chmod 檔案：
find . -type f -exec chmod 0600 {} \;

2. 在當前目錄下遁迴 chmod 目錄：
find . -type d -exec chmod 0755 {} \; </description>
		<link>http://www.real-blog.com/linux-bsd-notes/527</link>
			</item>
</channel>
</rss>
