使用者工具

網站工具


tech:install_mailwatch

安裝 MailWatch 方式

MailWatch 可以統計 MailScanner 的運作狀況, 並將之存到 MySQL 協助管理的工具

  • 下載 MailWatch
    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
  • 編輯 php.ini
    vi /etc/php.ini
    :
    magic_quotes_gpc = On
    :
  • 透過 phpMyAdmin 在 MySQL 建立 MailWatch 所需要的資料表
    1. 建立 mailscanner 資料庫
    2. 將 create.sql 內容貼入執行, 建立資料表
    3. 建立 mailwatch 資料庫使用者可以存取 mailscanner 資料庫
  • 建立網頁目錄與權限
    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
  • 建立 conf.php
    cp conf.php.example conf.php
    vi conf.php
    :
    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);
    :
  • 編輯 MailWatch.pm 與複製到 MailScanner 自訂函數目錄
    vi MailWatch.pm
    :
    # 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';
    :
    cp MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
  • 調整 MailScanner 設定
    service MailScanner stop
    vi /etc/MailScanner/MailScanner.conf
    :
    # 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
    :
  • 設定整合編輯 Blacklist/Whitelist
    vi SQLBlackWhiteList.pm
    :
    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';
    :
    cp SQLBlackWhiteList.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
    vi /etc/MailScanner/MailScanner.conf 
    :
    Is Definitely Not Spam = &SQLWhitelist
    :
    Is Definitely Spam = &SQLBlacklist
    :
  • 編輯 Bayesian Databases 啟動權限
    vi /etc/MailScanner/spam.assassin.prefs.conf
    :
    # 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
    :
    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_*
  • 重新啟動 MailScanner
    service MailScanner start && tail -f /var/log/maillog
  • 如果 MySQL 安裝在其他主機, 要更改 /var/www/html/mailscanner/geoip_update.php
    :
    dbquery("LOAD DATA LOCAL INFILE '".$base.'/'.$file2."' INTO TABLE geoip_country FIELDS TERMINATED BY ',' ENCLOSED BY '\"'");
    :

    這樣才可順利匯入, 否則會出現類似以下的錯誤訊息

    Downloading file, please wait....
    Error executing query: 
    
    Access denied for user 'mailwatch'@'192.168.11.xx' (using password: YES)

參考網址

tech/install_mailwatch.txt · 上一次變更: 2011/06/30 16:55 由 jonathan