mailwatch安裝

MAILWATCH的安裝

開始安裝之前
必需有一個可以工作的mailscanner,安裝MYSQL,Apache,PHP(支援MYSQL,GD模組),為了讓mailscanner可以使用資料庫所以必需替perl安裝DBD及DBD::mysql模組

一般在PHP上都會安裝GD及MYSQL模組,而PERL則用cpan這個工具來安裝 首先cpan YAML再來cpan DBI 和cpan DBD::mysql

build-essential 建立必要的套件其中內含 gcc 套件

mailwatch可以到這網址 http://mailwatch.sourceforge.net/doku.php 下載

將下載下來的壓縮檔解壓縮進到其目錄底下,在這之前我們應該已經安裝了mqsql server的套件並建立資料庫的管理者帳號。

接著利用壓縮檔內的create.sql這個檔案建立mailwatch所需的資料庫
mysql GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY “;

mysql> GRANT FILE ON *.* TO mailwatch@localhost IDENTIFIED BY “;

mysql> FLUSH PRIVILEGES;

編輯 MailWatch.pm 且 更改設定變數 $db_user 和 $db_pass 的值,然後將MailWatch.pm 移動到 /usr/lib/MailScanner/MailScanner/CustomFunctions 這個目錄下面(這個目錄可能是這樣的 /opt/MailScanner/lib/MailScanner/MailScanner/CustomFunctions 如果不是經由安裝套件安裝的話路徑是不一樣的)

建立一個mailwatch的網頁使用者

# mysql mailscanner -u mailwatch -p
Enter password: ******

mysql> INSERT INTO users VALUES (‘username’,md5(‘password’),’username’,’A’,",",",",");

移動 mailscanner 目錄到網頁的根目錄下面

# mv mailscanner /var/www/html/

檢查 /var/www/html/mailscanner/images 及 /var/www/html/images/cache 這兩個目錄的權限, 權限應該是這樣的 ug+rwx 且 檔案的擁有者是 root 且檔案所有群組跟 web server user 是一樣的

切換到/var/www/html/mailscanner的目錄下面
# chown root:www-data images
# chmod ug+rwx images
# chown root:www-data images/cache
# chmod ug+rwx images/cache
note:ubuntu server 預設apache的群組是www-data

建立mailscanner之mailwatch網頁的設置檔 conf.php
藉由 copying conf.php.example 並且編輯合適的值 。
我們將會設定 DB_USER and DB_PASS the MySQL user and password (我們先前所建立的)。

# cp conf.php.example conf.php

配罝MailScanner
停止 MailScanner服務

#/etc/init.d/mailscanner stop
接著編輯 /etc/MailScanner/MailScanner.conf 我們所要確認的參數設定如下:

Always Looked Up Last = &MailWatchLogging
Detailed Spam Report = yes
Quarantine Whole Message = yes
Quarantine Whole Message As Queue Files = no
Include Scores In SpamAssassin Report = yes
Quarantine User = root
Quarantine Group = www-data
Quarantine Permissions = 0660

假如我們要讓MailWatch學習及觀看spam郵件,那我們應該要設定 Sapm Actions 和 High Spam Actions 為 “store"

假如我們要使用整合黑白名單(可選擇性的)

複製SQLBlackWhiteList.pm 到 /etc/MailScanner/CustomFunctions
然後編輯SQLBlackWhitelist.pm ,修改CreateList 副程式中的連線字串去符合MailWatch.pm

再來修改MailScanner.conf的設定
Is Definitely Not Spam = &SQLWhitelist
Is Definitely Spam = &SQLBlacklist

移動貝氐資料庫及設定權限(如不想使用貝氐可以略過些項設定).

編輯/etc/MailScanner/spam.assassin.prefs.conf設定如下:
bayes_path /etc/MailScanner/bayes/bayes
bayes_file_mode 0660

建立一個新的bayes目錄, 這目錄的所有群組是web server user 且 make the directory setgid:

# mkdir /etc/MailScanner/bayes
# chown root:www-data /etc/MailScanner/bayes
# chmod g+rws /etc/MailScanner/bayes

複製已存貝氐資料庫並修改權限

# cp /root/.spamassassin/bayes_* /etc/MailScanner/bayes
# chown root:www-data /etc/MailScanner/bayes/bayes_*
# chmod g+rw /etc/MailScanner/bayes/bayes_*

測試 SpamAssassin 去確認它正確地使用一個新的貝氐資料庫

# spamassassin -D -p /etc/MailScanner/spam.assassin.prefs.conf –lint

而我們將會看見以下的訊息

debug: using “/etc/MailScanner/spam.assassin.prefs.conf" for user prefs file
debug: bayes: 28821 tie-ing to DB file R/O /etc/MailScanner/bayes/bayes_toks
debug: bayes: 28821 tie-ing to DB file R/O /etc/MailScanner/bayes/bayes_seen
debug: bayes: found bayes db version 2
debug: Score set 3 chosen.

測試 MailWatch 介面
打開瀏覽器輸入網址 http:///mailscanner/ 將會看到提示輸入帳號及密碼

更新 SpamAssassin Rules table

MailWatch keeps a list of all the SpamAssassin rules and descriptions which are displayed on the ‘Message Detail’ page – to s
how the descriptions, you need to run the updater every time you add new rules or upgrade SpamAssassin.

Click on the ‘Other’ menu and select ‘Update SpamAssassin Rule Descriptions’ and click ‘Run Now’.

– Update the GeoIP database

Click on the ‘Other’ menu and select ‘Update GeoIP database’ and click ‘Run Now’.

– Setup the Mail Queue watcher (optional)

You can get MailWatch to watch and display your sendmail queue directories – all you need to do is copy mailq.php (from the root of the mailwatch tarball – not from the mailscanner directory – they are different!) to /usr/local/bin and set-up a cron-job to run it.

Edit mailq.php first to change the require line to point to the location of functions.php, then:
# cp mailq.php /usr/local/bin
# crontab -e
0-59 * * * * /usr/local/bin/mailq.php

Note: mailq.php re-creates all entries on each run, so for busy sites you will probably want to change this to run every 5 minutes or greater.

這是後來發現一些未安裝PERL的模組
Mail::SPF::Query #無法安裝
IP::Country::Fast
Razor2::Client::Agent
Net::Ident #無法安裝
IO::Socket::SSL
Mail::DomainKeys
Mail::DKIM
Encode::Detect

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s