差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:install_mailwatch [2011/06/13 18:59] jonathantech:install_mailwatch [2011/06/30 16:55] (目前版本) jonathan
行 1: 行 1:
 +====== 安裝 MailWatch 方式 ======
 +MailWatch 可以統計 MailScanner 的運作狀況, 並將之存到 MySQL 協助管理的工具
 +
 +  * 下載 MailWatch <code sh>
 +su - root
 +cd /var/www/html
 +wget http://sourceforge.net/projects/mailwatch/files/mailwatch/1.0.5/mailwatch-1.0.5.tar.gz/download
 +tar -zxvf mailwatch-1.0.5.tar.gz
 +mv mailwatch-1.0.5 mailwatch
 +cd mailwatch
 +</code>
 +  * 編輯 php.ini <code sh>
 +vi /etc/php.ini
 +</code><file>
 +:
 +magic_quotes_gpc = On
 +:
 +</file>
 +  * 透過 phpMyAdmin 在 MySQL 建立 MailWatch 所需要的資料表
 +    - 建立 mailscanner 資料庫
 +    - 將 create.sql 內容貼入執行, 建立資料表
 +    - 建立 mailwatch 資料庫使用者可以存取 mailscanner 資料庫
 +  * 建立網頁目錄與權限<code sh>
 +mv mailscanner /var/www/html
 +cd /var/www/html/mailscanner
 +chown root:apache images
 +chmod ug+rwx images
 +chown root:apache images/cache
 +chmod ug+rwx images/cache
 +</code>
 +  * 建立 conf.php <code sh>
 +cp conf.php.example conf.php
 +vi conf.php
 +</code><file>
 +:
 +define('DB_TYPE', 'mysql');
 +define('DB_USER', 'mailwatch');
 +define('DB_PASS', 'xxxx');
 +define('DB_HOST', '192.168.11.xx');
 +define('DB_NAME', 'mailscanner');
 +define('DB_DSN', DB_TYPE.'://'.DB_USER.":".DB_PASS."@".DB_HOST."/".DB_NAME);
 +:
 +</file>
 +  * 編輯 MailWatch.pm 與複製到 MailScanner 自訂函數目錄<code sh>
 +vi MailWatch.pm
 +</code><file>
 +:
 +# Modify this as necessary for your configuration
 +my($db_name) = 'mailscanner';
 +my($db_host) = '192.168.11.xx';
 +my($db_user) = 'mailwatch';
 +my($db_pass) = 'xxxx';
 +:
 +</file><code sh>
 +cp MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
 +</code>
 +  * 調整 MailScanner 設定<code sh>
 +service MailScanner stop
 +vi /etc/MailScanner/MailScanner.conf
 +</code><file>
 +:
 +# If you want to use it, read CustomConfig.pm.
 +Always Looked Up Last = &MailWatchLogging
 +:
 +# Do you want the full spam report, or just a simple "spam / not spam" report?
 +Detailed Spam Report = yes
 +:
 +# This can also be the filename of a ruleset.
 +Quarantine Whole Message = Yes
 +:
 +# as human-readable files (header then body in 1 file)?
 +Quarantine Whole Messages As Queue Files = no
 +:
 +# report, or just list the names of the scores
 +Include Scores In SpamAssassin Report = yes
 +:
 +#       and "Quarantine Group".
 +Quarantine User = root
 +Quarantine Group = apache
 +
 +# If you want processes running under the same *group* as MailScanner to
 +# be able to read the quarantined files (and list what is in the
 +# directories, of course), set to 0640. If you want *all* other users to
 +# be able to read them, set to 0644. For a detailed description, if
 +# you're not already familiar with it, refer to `man 2 chmod`.
 +# Typical use: let the webserver have access to the files so users can
 +# download them if they really want to.
 +# Use with care, you may well open security holes.
 +Quarantine Permissions = 0660
 +:
 +Spam Actions = store deliver header "X-Spam-Status: Yes"
 +:
 +High Scoring Spam Actions = store
 +:
 +</file>
 +  * 設定整合編輯 Blacklist/Whitelist <code sh>
 +vi SQLBlackWhiteList.pm
 +</code><file>
 +:
 +sub CreateList {
 +  my($type, $BlackWhite) = @_;
 +  my($dbh, $sth, $sql, $to_address, $from_address, $count);
 +  my($db_name) = 'mailscanner';
 +  my($db_host) = '192.168.11.xx';
 +  my($db_user) = 'mailwatch';
 +  my($db_pass) = 'xxxx';
 +:
 +</file><code>
 +cp SQLBlackWhiteList.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
 +vi /etc/MailScanner/MailScanner.conf 
 +</code><file>
 +:
 +Is Definitely Not Spam = &SQLWhitelist
 +:
 +Is Definitely Spam = &SQLBlacklist
 +:
 +</file>
 +  * 編輯 Bayesian Databases 啟動權限<code sh>
 +vi /etc/MailScanner/spam.assassin.prefs.conf
 +</code><file>
 +:
 +# Thanks to Matt Kettler for pointing this out.
 +bayes_path /etc/MailScanner/bayes/bayes
 +
 +
 +# This is actually used as a mask, not a raw chmod setting.
 +# Thanks for Matt Kettler for spotting this one.
 +# Commented out: this if for MailWatch and Exim/Postfix users only.
 + bayes_file_mode 0660
 +:
 +</file><code sh>
 +mkdir /etc/MailScanner/bayes
 +chown root:apache /etc/MailScanner/bayes
 +chmod g+rws /etc/MailScanner/bayes
 +cp /root/.spamassassin/bayes_* /etc/MailScanner/bayes
 +chown root:apache /etc/MailScanner/bayes/bayes_*
 +chmod g+rw /etc/MailScanner/bayes/bayes_*
 +</code>
 +  * 重新啟動 MailScanner <code sh>
 +service MailScanner start && tail -f /var/log/maillog
 +</code>
 +
 +<note important>
 +  * 如果 MySQL 安裝在其他主機, 要更改 /var/www/html/mailscanner/geoip_update.php<file>
 +:
 +dbquery("LOAD DATA LOCAL INFILE '".$base.'/'.$file2."' INTO TABLE geoip_country FIELDS TERMINATED BY ',' ENCLOSED BY '\"'");
 +:
 +</file> 這樣才可順利匯入, 否則會出現類似以下的錯誤訊息<code>
 +Downloading file, please wait....
 +Error executing query: 
 +
 +Access denied for user 'mailwatch'@'192.168.11.xx' (using password: YES)
 +</code>
 +</note>
 +
 +===== 參考網址 =====
 +  * http://dev.mysql.com/doc/refman/5.1/en/load-data-local.html
 +
 +{{tag>mail mailscanenr}}