此操作只适合emos1.6 64位版本
PS:emos1.5 32位版本也可以用第三方的源来更新dspam,操作步骤和64位系统一样。注意dspam.conf配置里面的StorageDriver /usr/lib/dspam/libmysql_drv.soPS:32位源:
wget http://dl.fedoraproject.org/pub/ ... ease-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
clamav升级到ClamAV 0.97.6
dspam升级到 DSPAM Anti-Spam Suite 3.10.2 (agent/library)
1,添加第三方更新源EPEL
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
2,升级 clamav
service clamd stop
service postfix stop
yum update clamav
#修改clamav所有者和所有组:
#chown clamav:clamav /var/run/clamav(不做)
service clamd start
service postfix start
更新病毒定义
freshclam
查看版本
clamd -V
ClamAV 0.97.6
4,卸载原来的dspam
service dspamd stop
service dspam-webd stop
rpm -qa |grep dspam |xargs rpm -e --nodeps
rm -fr /usr/share/dspam/
5,修改dspam的ID
userdel dspam
groupadd -g 2000 dspam
useradd -g dspam -u 2000 dspam
6,yum安装dspam
yum -y install dspam-libs dspam-client dspam-devel dspam-mysql dspam-hash dspam-web dspam
7,修改dspam.conf
vi /etc/dspam.conf
Home /var/lib/dspam
StorageDriver /usr/lib64/dspam/libmysql_drv.so
TrustedDeliveryAgent "/usr/bin/sendmail"
DeliveryHost 127.0.0.1
DeliveryPort 10024
DeliveryIdent localhost
DeliveryProto SMTP
OnFail error
Trust root
Trust dspam
Trust extmail
Trust amavis
Trust vuser
Trust extmail
TrainingMode teft
TestConditionalTraining on
Feature whitelist
#Feature tb=3
Algorithm graham burton
Tokenizer chain
PValue bcr
WebStats on
Preference "trainingMode=TEFT" # { TOE | TUM | TEFT | NOTRAIN } -> default:teft
Preference "spamAction=quarantine" # default:quarantine
Preference "spamSubject=[SPAM]" # { string } -> default:[SPAM]
Preference "statisticalSedation=5" # { 0 - 10 } -> default:0
Preference "enableBNR=on" # { on | off } -> default:off
Preference "enableWhitelist=on" # { on | off } -> default:on
Preference "signatureLocation=message" # default:message
Preference "tagSpam=off" # { on | off }
Preference "tagNonspam=off" # { on | off }
Preference "showFactors=off" # { on | off } -> default:off
Preference "optIn=off" # { on | off }
Preference "optOut=off" # { on | off }
Preference "whitelistThreshold=10" # { Integer } -> default:10
Preference "makeCorpus=off" # { on | off } -> default:off
Preference "storeFragments=off" # { on | off } -> default:off
Preference "localStore=" # { on | off } -> default:username
Preference "processorBias=on" # { on | off } -> default:on
Preference "fallbackDomain=off" # { on | off } -> default:off
Preference "trainPristine=off" # { on | off } -> default:off
Preference "optOutClamAV=off" # { on | off } -> default:off
Preference "ignoreRBLLookups=off" # { on | off } -> default:off
Preference "RBLInoculate=off" # { on | off } -> default:off
AllowOverride enableBNR
AllowOverride enableWhitelist
AllowOverride fallbackDomain
AllowOverride ignoreGroups
AllowOverride ignoreRBLLookups
AllowOverride localStore
AllowOverride makeCorpus
AllowOverride optIn
AllowOverride optOut
AllowOverride optOutClamAV
AllowOverride processorBias
AllowOverride RBLInoculate
AllowOverride showFactors
AllowOverride signatureLocation
AllowOverride spamAction
AllowOverride spamSubject
AllowOverride statisticalSedation
AllowOverride storeFragments
AllowOverride tagNonspam
AllowOverride tagSpam
AllowOverride trainPristine
AllowOverride trainingMode
AllowOverride whitelistThreshold
AllowOverride dailyQuarantineSummary
MySQLServer /var/lib/mysql/mysql.sock
MySQLUser dspam
MySQLPass password123 #密码为mysql dspam的密码,后面会设置的
MySQLDb dspam
MySQLCompress true
MySQLReconnect true
MySQLConnectionCache 1
MySQLUIDInSignature on
Notifications off
PurgeSignatures 14 # Stale signatures
PurgeNeutral 90 # Tokens with neutralish probabilities
PurgeUnused 90 # Unused tokens
PurgeHapaxes 30 # Tokens with less than 5 hits (hapaxes)
PurgeHits1S 15 # Tokens with only 1 spam hit
PurgeHits1I 15 # Tokens with only 1 innocent hit
LocalMX 127.0.0.1
SystemLog on
UserLog on
Opt out
ServerPort 10028
ServerQueueSize 32
ServerPID /var/run/dspam/dspamd.pid
ServerMode auto
ServerPass.Relay1 "secret"
ServerParameters "--user extmail --deliver=innocent,spam -d %u"
ServerIdent "localhost.localdomain"
ClientHost 127.0.0.1
ClientPort 10028
ClientIdent "secret@Relay1"
ProcessorURLContext on
ProcessorBias on
StripRcptDomain off
8,导入数据库文件
备份mysql原来dspam的数据
mysqldump -u root -p --opt dspam > /root/dspam-backup.sql
Enter password: #mysql root的密码
删除mysql dspam数据库
mysql -p
Enter password: #mysql root的密码
mysql>drop database dspam; #注意带分号
重启mysql
service mysqld restart
创建dspam所需的数据库
mysql -u root -p -e "create database dspam"
Enter password:
mysql -u root -p -e "grant all on dspam.* to dspam@localhost identified by 'password123'" #此处密码和dspam.conf链接数据库密码一致
Enter password:
导入数据表
cd /usr/share/dspam/sql-scripts/mysql
mysql -u dspam -pmydriver dspam < mysql_objects-4.1.sql
mysql -u dspam -pmydriver dspam < virtual_users.sql
4、DSPAM的token数据库的定时清理:
# crontab -e
修改加入以下内容:
0 0 * * * /usr/bin/mysql -u dspam -p'password123' dspam < /usr/share/dspam/sql-scripts/mysql/
0 0 * * * /usr/bin/dspam_logrotate -a 30 -d /var/spool/dspam/data
5,设置dspam.conf权限
chown -Rf dspam:mail /etc/dspam.conf #最重要,不然dspam web会出错,没有数据
6、启动dspam服务
chkconfig dspam on
/etc/init.d/dspam start
7、查看服务有没有正常启动;
查看dspam启动进程
# ps aux |grep dspam
root 16807 0.0 0.1 61488 2108 pts/0 S 17:23 0:00 /usr/bin/dspam --daemon
root 16813 0.0 0.0 61240 776 pts/0 S+ 17:23 0:00 grep dspam
8,增加apache配置文件,衔接dspam配置文件,在最后一行追加信息
vi /etc/httpd/conf/httpd.conf
NameVirtualHost *:81
Include conf/81_*.conf
建立dspam虚拟主机配置文件
vi /etc/httpd/conf/81_dspam.conf
Listen 81
<VirtualHost *:81>
ServerName spam.shen.cn #此处改成你自己的
ServerAdmin postmaster@localhost
DocumentRoot /var/www/dspam
SuexecUserGroup dspam dspam
Options Indexes FollowSymLinks ExecCGI
<Directory "/var/www/dspam">
AllowOverride None
Options -Indexes +ExecCGI
Order allow,deny
Allow from all
AuthType Basic
AuthName "DSPAM WebUI login"
AuthUserFile /var/www/dspam/.htpasswd
Require valid-user
DirectoryIndex dspam.cgi
AddHandler cgi-script .cgi .pl
</Directory>
ErrorLog /var/log/httpd/dspam-webgui-error_log
CustomLog /var/log/httpd/dspam-webgui-access_log common
</VirtualHost>
9,创建dspam-web 认证用户:
cd /var/www/dspam
echo "extmail" > admins
htpasswd -c .htpasswd extmail
输入认证密码
New password:
Re-type new password:
Adding password for user dspam
10,更改iptables防火墙
vi /etc/sysconfig/iptables
加入
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 81 -j ACCEPT
重启iptables
service iptables restart
重启HTTPD
service httpd restart
访问dspam web
http://your ip:81
测试不能通过web界面收发邮件,不然dspam web会没有数据,通过客户端自己发自己邮件dspam web就会显示数据。
如果在升级clamav后,启动出现错误,请执行以下步骤
yum remove clamd clamav
yum install clamd
rm /var/log/clamav/freshclam.log
freshclam