Part 14 - Clam Antivirus & SpamAssassin
安装需要perl模块,需要先切换到非root用户进行检查
su bsmith
/downloads/qmailrocks/scripts/util/check_perlmods.script
检测完成后,缺少Parse::Syslog 和 Statistics::Distributions 模块
安装需要perl模块,需要先切换到非root用户进行检查
su bsmith
/downloads/qmailrocks/scripts/util/check_perlmods.script
检测完成后,缺少Parse::Syslog 和 Statistics::Distributions 模块
安装对应的rpm包然后重新检测,直到都通过
exit
cd /downloads/qmailrocks/
exit
cd /downloads/qmailrocks/
rpm -Uvh clamav-x.x-x.x.rpm
rpm -Uvh clamav-devel-x.x-x.x.rpm
/etc/init.d/clamd start
用root用户启动clamav生成/var/log/clamav/clamd.log
用root用户启动clamav生成/var/log/clamav/clamd.log
vi /etc/clamd.conf
"Example" - 全部注释掉(#)
"LogFile" - 设置为 /var/log/clamav/clamd.log
"LogTime" - 不注释
"LogSyslog" - 不注释
"User" - 设置为 qscand
"ScanMail" - 不注释
useradd -c "Qmail-Scanner Account" -s /bin/false qscand
chown qscand:qscand /var/log/clamav/clamd.log
"Example" - 全部注释掉(#)
"LogFile" - 设置为 /var/log/clamav/clamd.log
"LogTime" - 不注释
"LogSyslog" - 不注释
"User" - 设置为 qscand
"ScanMail" - 不注释
useradd -c "Qmail-Scanner Account" -s /bin/false qscand
chown qscand:qscand /var/log/clamav/clamd.log
/etc/init.d/clamd stop
/etc/init.d/clamd start
升级病毒库并将日志记录在log中
/usr/bin/freshclam -l /var/log/clamav/clam-update.log
crontab -e
25 1 * * * /usr/bin/freshclam --quiet -l /var/log/clamav/freshclam.log
cd /downloads/qmailrocks/perlmods/rpms/
先检查是否已经安装了SpamAssassin
rpm -qa | grep SpamAssassin*
如果已经有了需要先卸载 rpm -e SpamAssassin*
rpm -Uvh perl-Mail-SpamAssassin-3.0.2-1.i386.rpm
cd /downloads/qmailrocks/
rpm -ivh perl-DateManip-5.42a-3.noarch.rpm (spam依赖的包)
rpm -Uvh spamassassin-3.0.2-1.i386.rpm spamassassin-tools-3.0.2-1.i386.rpm
rpm -Uvh spamassassin-3.0.2-1.i386.rpm spamassassin-tools-3.0.2-1.i386.rpm
groupadd spamd
useradd -g spamd -s /home/spamd spamd
vi /etc/sysconfig/spamassassin
If the above file exists, replace its contents with the following line. If the file does not exist, create it and add the following line:
SPAMDOPTIONS="-x -u spamd -H /home/spamd -d"
vi /etc/mail/spamassassin/local.cf
Add the following line...
required_hits 5
/etc/rc.d/init.d/spamassassin start
Now let's see if Spamassassin is running...
ps aux | grep spamd
添加clamd和Spamassassin开机自启动
chkconfig clamd on
chkconfig spamassassin on
Part 15 - qmail-scanner w/qms-analog
cd /downloads/qmailrocks
cd /downloads/qmailrocks
tar zxvf qmail-scanner-1.25.tgz
tar zxvf qms-analog-0.4.4.tar.gz
cd qms-analog-0.4.4
make all
cp qmail-scanner-1.25-st-qms-20050618.patch /downloads/qmailrocks/qmail-scanner-1.25/
cd /downloads/qmailrocks/qmail-scanner-1.25
patch -p1 < qmail-scanner-1.25-st-qms-20050618.patch
vi qms-config
修改红色部分
#!/bin/sh
if [ "$1" != "install" ]; then
INSTALL=
else
INSTALL="--install"
fi
INSTALL=
else
INSTALL="--install"
fi
./configure --domain yourdomain.com \
--admin postmaster \
--local-domains "yourdomain.com,yourotherdomain.com" \
--add-dscr-hdrs yes \
--dscr-hdrs-text "X-Antivirus-MYDOMAIN" \
--ignore-eol-check yes \
--sa-quarantine 0 \
--sa-delete 0 \
--sa-reject no \
--sa-subject ":SPAM:" \
--sa-delta 0 \
--sa-alt yes \
--sa-debug no \
--notify admin \
"$INSTALL"
--admin postmaster \
--local-domains "yourdomain.com,yourotherdomain.com" \
--add-dscr-hdrs yes \
--dscr-hdrs-text "X-Antivirus-MYDOMAIN" \
--ignore-eol-check yes \
--sa-quarantine 0 \
--sa-delete 0 \
--sa-reject no \
--sa-subject ":SPAM:" \
--sa-delta 0 \
--sa-alt yes \
--sa-debug no \
--notify admin \
"$INSTALL"
运行一个测试脚本来测试qmail-scaner
chmod 755 qms-config
./qms-config
没有错误提示开始安装./qms-config install
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -z
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -g
应该看到类似的显示信息在屏幕上
perlscanner: generate new DB file from /var/spool/qmailscan/quarantine-p_w_uploads.txt
perlscanner: total of 9 entries.
perlscanner: total of 9 entries.
chown -R qscand:qscand /var/spool/qmailscan
vi /var/qmail/supervise/qmail-smtpd/run
编辑此脚本,在第一行添加
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl" ; export QMAILQUEUE
并修改 softlimit to 40000000
qmailctl stop
qmailctl start
cd /downloads/qmailrocks/qmail-scanner-1.25/contrib
cd /downloads/qmailrocks/qmail-scanner-1.25/contrib
chmod 755 test_installation.sh
./test_installation.sh -doit
执行此脚本后能看到一些测试信息
然后登陆webmail,查看是否收到2封测试邮件,收到说明测试通过
Part 16 - QmailAnalog w/qlogtools & qms-analog
cd /downloads/qmailrocks/
tar zxvf qmailanalog-0.70.tar.gz
cd qmailanalog-0.70
patch < /downloads/qmailrocks/patches/0.70-errno.patch
make && make setup check
cd /downloads/qmailrocks/
tar zxvf qlogtools-3.1.tar.gz
cd qlogtools-3.1
patch < /downloads/qmailrocks/patches/qlogtools_errno.patch
mkdir /usr/local/man
make
./installer
cp /downloads/qmailrocks/qms-analog-0.4.2/qmailstats /var/qmail/bin
vi /var/qmail/bin/qmailstats
编辑修改红色部分
## build the email message header
echo "To: [email]your_postmaster@yourdomain.com[/email] " > $EMAILMSG
echo "From: [email]your_postmaster@yourdomain.com[/email] " >> $EMAILMSG
echo "Subject: Nightly Qmail Stats Report for $DATE" >> $EMAILMSG
echo "" >> $EMAILMSG
echo "" >> $EMAILMSG
echo "To: [email]your_postmaster@yourdomain.com[/email] " > $EMAILMSG
echo "From: [email]your_postmaster@yourdomain.com[/email] " >> $EMAILMSG
echo "Subject: Nightly Qmail Stats Report for $DATE" >> $EMAILMSG
echo "" >> $EMAILMSG
echo "" >> $EMAILMSG
chmod 750 /var/qmail/bin/qmailstats
/var/qmail/bin/qmailstats
crontab -e
0 3 * * * /var/qmail/bin/qmailstats 1>/dev/null 2>/dev/null
Part 17 - Installing Qtrap
cd /home/vpopmail
mkdir -p qtrap/logs
cd qtrap
cp /downloads/qmailrocks/scripts/qtrap/qtrap-2.0.0 ./qtrap.sh
vi qtrap.sh
You will see a block of code for the whitelist that looks like this:
whitelist_check () {
case $WHITELIST in
[email]address@somewhere.com[/email]|[email]address@somewhereelse.com[/email]|*entiredomain.com)
echo $SENDER found in whitelist on `date "+%D %H:%M:%S"` >> /home/vpopmail/qtrap/logs/qtrap.log
exit 0;;
*)
;;
esac
}
case $WHITELIST in
[email]address@somewhere.com[/email]|[email]address@somewhereelse.com[/email]|*entiredomain.com)
echo $SENDER found in whitelist on `date "+%D %H:%M:%S"` >> /home/vpopmail/qtrap/logs/qtrap.log
exit 0;;
*)
;;
esac
}
红色字为白名单(不经过qtrap过滤)
checkall () {
case $BANNED_WORDS in
porn|PORN|Sex|SEX)
printout $BANNED_WORDS
echo MESSAGE DROPPED from $SENDER because of $BANNED_WORDS on `date "+%D %H:%M:%S"` >> /home/vpopmail/qtrap/logs/qtrap.log
exit 99;;
*)
case $BANNED_WORDS in
porn|PORN|Sex|SEX)
printout $BANNED_WORDS
echo MESSAGE DROPPED from $SENDER because of $BANNED_WORDS on `date "+%D %H:%M:%S"` >> /home/vpopmail/qtrap/logs/qtrap.log
exit 99;;
*)
红色词为(过滤关键词)
touch /home/vpopmail/qtrap/logs/qtrap.log
chown -R vpopmail:vchkpw /home/vpopmail/qtrap
chmod -R 755 /home/vpopmail/qtrap
Now we will add this script into the mail path for a domain on our server.
cd /home/vpopmail/domains/yourdomain.com
vi .qmail-default
编辑在第一行插入
| /home/vpopmail/qtrap/qtrap.sh
然后发送带有红色过滤词的邮件,看是否可以过滤
Part 18 - Maintaining your qmail server
确认所有需要的服务都会开机启动
Courier-imap SpamAssassin httpd MySQL
vi /etc/rc.local
加入
/etc/rc.d/init.d/imap start
/etc/rc.d/init.d/imaps start
/etc/rc.d/init.d/imaps start
chkconfig httpd on
chkconfig mysqld on
最后用setup检查一下.
收发邮件正常,只是有一点小bug
启动apache时提示Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
编辑httpd
编辑httpd
vi /etc/httpd/conf/httpd.conf
找到ServerName 去掉前面的#,然后把后面改成自己需要的名称
转载于:https://blog.51cto.com/coolerfeng/76507