作者:NiCK.linux
Qmail on SuSE8.2
此文根据www.qmailrocks.org的安装文档做的修改(该网站还未退出suse的安装文档),主要修改地方一个是OS,把Redhat linux换成了SuSE linux 8.2,另一个是杀毒软件,把Clam Anti-Virus换成了Mcafee。
本人使用此邮件系统1年,非常好,所以把安装文档拿出来和大家分享,谢谢!
准备安装
请检查下列rpm包是否已经安装,如果没有安装,可以到SuSE安装光盘上面去找,或者到http://www.mirror.ac.uk/sites/ftp.suse.com/pub/去下载
patchutils
db-devel
compat
perl-Digest-SHA1
perl-Digest-HMAC
perl-HTML-Parser
perl-HTML-Tagset
perl-Net-DNS
perl-spamassassin
spamassassin
openssl-devel
xinetd
1、安装mysql、apache2、php-4.3.6,具体的我就不说了?
apache2编译时需要参数:
--enable-so
php 编译时需要参数:
--enable-track-vars
--enable-force-cgi-redirect
--with-gettext
--with-mysql
--with-apxs2=/usr/local/apache2/bin/apxs
2、下载相关软件包
mkdir /downloads
cd /downloads
wget http://www.qmailrocks.org/downloads/qmailrocks.tar.gz
tar zxvf qmailrocks.tar.gz
3、安装Qmail
cd /downloads/qmailrocks
mkdir -p /var/qmail
./scripts/add_users.script (创建组和帐号)
mkdir /usr/src/qmail
cd /usr/src/qmail
tar zxvf /downloads/qmailrocks/qmail-1.03.tar.gz
tar zxvf /downloads/qmailrocks/ucspi-tcp-0.88.tar.gz
mkdir -p /package
chmod 1755 /package
cd /package
tar zxvf /downloads/qmailrocks/daemontools-0.76.tar.gz
设置log目录
mkdir /var/log/qmail
cd /var/log/qmail
mkdir qmail-send qmail-smtpd qmail-pop3d
chown -R qmaill:root /var/log/qmail
chmod -R 750 /var/log/qmail
设置 supervise 目录
mkdir /var/qmail/supervise
cd /var/qmail/supervise
mkdir -p qmail-smtpd/log qmail-send/log qmail-pop3d/log
chmod +t qmail-smtpd qmail-send qmail-pop3d
自定义qmail源码
echo 200 > /usr/src/qmail/qmail-1.03/conf-split
echo 255 > /usr/src/qmail/qmail-1.03/conf-spawn
打补丁
/downloads/qmailrocks/scripts/qmail_patches.script
安装qmail
cd /usr/src/qmail/qmail-1.03
patch < /downloads/qmailrocks/patches/qmail-1.03.errno.patch
make man && make setup check
./config-fast heming.org(根据你的域名修改,下面再出现heming.org请自己修改,我就不说了)
安装ucspi-tcp
cd /usr/src/qmail/ucspi-tcp-0.88/
patch < /downloads/qmailrocks/patches/ucspi-tcp-0.88.errno.patch
make && make setup check
安装daemontools
cd /package/admin/daemontools-0.76
cd /package/admin/daemontools-0.76/src
patch < /downloads/qmailrocks/patches/daemontools-0.76.errno.patch
cd /package/admin/daemontools-0.76
package/install
4、安装QmailAnalog w/qlogtools,qmail log分析工具
安装 qmailanalog
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
安装 qlogtools...
cd /downloads/qmailrocks/
tar zxvf qlogtools-3.1.tar.gz
cd qlogtools-3.1
patch < /downloads/qmailrocks/patches/qlogtools_errno.patch
make
./installer
安装tai64nlocal
cd /downloads/qmailrocks/
wget http://archives.eyrie.org/software/system/tai64nfrac-1.4.tar.gz
tar xzvf tai64nfrac-1.4.tar.gz
cd tai64nfrac-1.4/
make install
设置Qmailanalog Report
vi /var/qmail/qmailstats
==========================
#!/bin/sh
# Qmailanalog invocation script
PATH=/usr/local/qmailanalog/bin:/var/qmail/bin:/bin:/usr/bin:/usr/local/bin
QMAILSTATS="/tmp/q.$$"
umask 077
cat /var/log/qmail/qmail-send/* /var/log/qmail/qmail-pop3d/* /var/log/qmail/qmail-smtpd/* | /usr/local/bin/tai64nlocal |matchup | tai64n2tai > $QMAILSTATS 5>/dev/null
DATE=`date +'%D'`
echo "To: postmaster@heming.org " >> qmailstats.email
echo "From: postmaster@heming.org" >> qmailstats.email
echo "Subject: [SERVER] Nightly Qmail Stats Report for $DATE" >> qmailstats.email
echo "" >> qmailstats.email
zoverall < $QMAILSTATS >> qmailstats.email
zfailures < $QMAILSTATS >> qmailstats.email
zdeferrals < $QMAILSTATS >> qmailstats.email
cat qmailstats.email | qmail-inject
rm -f $QMAILSTATS
rm -f qmailstats.email
==========================
chmod 750 /var/qmail/qmailstats
设置crontab...
crontab -e
01 0 * * * /var/qmail/qmailstats
5、安装EZmlm,qmail的mailing list
cd /downloads/qmailrocks/
tar zxvf ezmlm-0.53-idx-0.41.tar.gz
cd ezmlm-0.53-idx-0.41
make && make setup
6、安装Autoresponder
cd /downloads/qmailrocks
tar zxvf autorespond-2.0.2.tar.gz
cd autorespond-2.0.2
make && make install
7、安装Vpopmail
cd /downloads/qmailrocks
tar zxvf vpopmail-5.4.0.tar.gz
cd vpopmail-5.4.0
./configure --enable-logging=p
make && make install-strip
8、安装Vqadmin
cd /downloads/qmailrocks
tar zxvf vqadmin-2.3.2.tar.gz
cd vqadmin-2.3.2
./configure --enable-cgibindir=/path/to/your/cgi-bin --enable-htmldir=/path/to/your/html/directory
(例如:./configure --enable-cgibindir=/usr/local/http48/cgi-bin --enable-htmldir=/home/email)
make && make install-strip
vi /usr/local/http48/conf/httpd.conf
加入以下配置
==============================
<Directory "/path/to/your/cgi-bin/vqadmin">
deny from all
Options ExecCGI
AllowOverride AuthConfig
Order deny,allow
</Directory>
===============================
cd /path/to/your/cgi-bin/vqadmin
vi .htaccess
=====================
AuthType Basic
AuthUserFile /usr/local/http48/conf/vqadmin.passwd
AuthName vQadmin
require valid-user
satisfy any
=====================
chown nobody .htaccess
chmod 644 .htaccess
/usr/local/http48/bin/htpasswd -bc /usr/local/http48/conf/vqadmin.passwd admin passwd
/usr/local/http/bin/apachectl restart
访问http://www.yourdomain.com/cgi-bin/vqadmin/vqadmin.cgi
9、安装Maildrop,邮件过滤代理
cd /downloads/qmailrocks
tar zxvf maildrop-1.6.0.tar.gz
cd maildrop-1.6.0
./configure --prefix=/usr/local --exec-prefix=/usr/local --enable-maildrop-uid=root --enable-maildrop-gid=vchkpw --enable-maildirquota
make && make install-strip && make install-man
10、安装Qmailadmin
cd /downloads/qmailrocks
tar zxvf qmailadmin-1.2.0.tar.gz
cd qmailadmin-1.2.0
./configure --enable-cgibindir=/path/to/your/cgi-bin --enable-htmldir=/path/to/your/html/directory
make && make install-strip
访问http://www.yourdomain.com/cgi-bin/qmailadmin
11、删除 Sendmail
/etc/init.d/postfix stop
rpm -e --nodeps postfix-2.0.6-8
mv /usr/lib/sendmail /usr/lib/sendmail.old
mv /usr/sbin/sendmail /usr/sbin/sendmail.old
chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
12、完善 Qmail
cd /var/qmail/supervise
vi qmail-pop3d/run
==================
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec tcpserver -H -R -v -c100 0 110 qmail-popup mail.heming.org \
/home/vpopmail/bin/vchkpw qmail-pop3d Maildir 2>&1
========================
vi qmail-pop3d/log/run
=================================
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-pop3d 2>&1
=================================
vi qmail-smtpd/run
================================
#!/bin/sh
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 30000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/var/qmail/bin/qmail-smtpd mail.heming.org \
/home/vpopmail/bin/vchkpw /usr/bin/true 2>&1
==========================
vi qmail-smtpd/log/run
=============
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-smtpd 2>&1
==============
vi qmail-send/run
=========
#!/bin/sh
exec /var/qmail/rc
============
vi qmail-send/log/run
=========
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-send 2>&1
========================
cp /downloads/qmailrocks/scripts/finalize/rc /var/qmail/
cp /downloads/qmailrocks/scripts/finalize/qmailctl /var/qmail/bin/
/downloads/qmailrocks/scripts/finalize/set_perms_plus.script
qmailctl stop
echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp
qmailctl cdb
echo song@heming.org > /var/qmail/alias/.qmail-root
echo song@heming.org > /var/qmail/alias/.qmail-postmaster
echo song@heming.org > /var/qmail/alias/.qmail-mailer-daemon
ln -s /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-anonymous
chmod 644 /var/qmail/alias/.qmail*
echo badmail > /var/qmail/control/bouncefrom
测试qmail的script
/downloads/qmailrocks/scripts/qmr_inst_check
qmailctl stop
qmailctl start
qmailctl stat
看到如下信息就应该qmail进程已经起来
/service/qmail-send: up (pid 18035) 34 seconds
/service/qmail-send/log: up (pid 18036) 34 seconds
/service/qmail-smtpd: up (pid 18270) 0 seconds
/service/qmail-smtpd/log: up (pid 18268) 1 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0
13安装 Courier-imap/imaps ,支持IMAP, 安装Courierpassd,支持修改mailbox密码
cd /downloads/qmailrocks/
tar jxvf courier-imap-3.0.3.tar.bz2
cd courier-imap-3.0.3
./configure --prefix=/usr/local --exec-prefix=/usr/local --with-authvchkpw --without-authldap --disable-
root-check --with-ssl --with-authchangepwdir=/usr/local/libexec/authlib
这里时间比较长,而且会出现很多相同的信息,一开始我以为是出错了,平凡切断查错,最后才知道信息就是这样的
make && make install-strip && make install-configure
cd /usr/local/etc
/usr/local/sbin/mkimapdcert
vi imapd-ssl修改下面两项
==========
IMAPDSSLSTART=YES
TLS_CERTFILE=/usr/local/share/imapd.pem
===========
建立启动脚本
cp /usr/local/libexec/imapd.rc /etc/init.d/imap
cp /usr/local/libexec/imapd-ssl.rc /etc/init.d/imaps
/etc/init.d/imap start
/etc/init.d/imaps start
安装 Courierpassd.
cd /downloads/qmailrocks
tar zxvf courierpassd-0.30.tar.gz
cd courierpassd-0.30
./configure --with-couriersrc=/downloads/qmailrocks/courier-imap-3.0.3
make && make install
cp /downloads/qmailrocks/courier-imap-3.0.3/authlib/authdaemon.passwd /usr/local/libexec/authlib/
cd /etc/xinetd.d
vi courierpassd
=================
service courierpassd
{
port = 106
socket_type = stream
protocol = tcp
user = root
server = /usr/local/sbin/courierpassd
server_args = -s imap
wait = no
only_from = 127.0.0.1
instances = 4
disable = no
}
==============
vi /etc/services最后加一行
==========
courierpassd 106/tcp #for /etc/xinetd.d/courierpassd
===========
/etc/init.d/xinetd restart
/etc/init.d/imap stop
/etc/init.d/imaps stop
/etc/init.d/imap start
/etc/init.d/imaps start
13、安装Squirrelmail,一个很好的webmail
cd /downloads/qmailrocks/
wget http://heanet.dl.sourceforge.net/sourceforge/squirrelmail/squirrelmail-1.4.3-RC1.tar.bz2
tar zxvf /path/to/squirrelmail-x.x.x.tar.gz
mv squirrelmail-x.x.x webmail
mkdir /var/sqattachements
chown -R nobody:nogroup /var/sqattachements
cd webmail
chown -R nobody:nogroup data
cd config
./conf.pl
修改一下2项,第一项改成服务器的ip,第二项吧none改成login
=======================
1. Domain : 1.2.3.4 (Enter the IP of your server here. Don't be an idiot and actually use 1.2.3.4)
7. SMTP Authentication : login
==============================
http://www.yourdomain.com/webmail
patch change password
cd /path/to/squirrelmail_directory/plugins
wget http://unc.dl.sourceforge.net/sourceforge/sm-plugins/change_pass-2.6-1.4.x.tar.gz
tar zxvf change_pass-2.6-1.4.x.tar.gz
cd /path/to/squirrelmail_directory/config
./conf.pl
选择plugins,选择 change password
14安装Mcafee uvscan、spam、Qmail-Scanner
tar xvzf vlnx424l.tar.z
./install-uvscan
测试./uvscan -rc /tmp
升级 engine 和 dat,ftp.nai.com,下载下来直接覆盖原来的就可以
安装spam
install spamassassin.rpm
groupadd spamd
useradd -g spamd -s /bin/false spamd
vi /etc/sysconfig/spamd
加入一行SPAMDOPTIONS="-x -u spamd -H /home/spamd -d"
vi /etc/mail/spamassassin/local.cf
加入一行required_hits 5
/etc/init.d/spamd start
安装Qmail-Scanner
cd /downloads/qmailrocks
tar zxvf qmail-scanner-1.21.tgz
patch -p0 < q-s-1.21st-20040324.patch
groupadd qscand
useradd -c "Qmail-Scanner Account" -s /bin/false qscand -g qscand
chown root /usr/bin/suidperl
chmod 4711 /usr/bin/suidperl
cd qmail-scanner-1.21/
./configure --admin postmaster --domain heming.org --notify admin --local-domains heming.org --sa-delete 0
./configure --install --admin postmaster --domain heming.org --notify admin --local-domains heming.org --sa-delete 0
vi /var/qmail/supervise/qmail-smtpd/run
在#!/bin/sh下面加入一行QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl" export QMAILQUEUE
把softlimit 改成40000000
15、安装 Qtrap,通过检查邮件标题进行邮件过滤
cd /home/vpopmail
mkdir spamcheck
cd spamcheck
cp /downloads/qmailrocks/scripts/qtrap-1.2 ./
vi qtrap-1.2
找到porn|PORN|Sex|SEX,这里是你需要禁止的一些词组的一个个数组,你可以根据你的需要设置
mkdir logs
cd logs
touch qtrap.log
chown -R vpopmail:vchkpw /home/vpopmail/spamcheck
chmod -R 755 /home/vpopmail/spamcheck
cd /home/vpopmail/domains/heming.org
vi .qmail-default
最上面增加一行| /home/vpopmail/spamcheck/qtrap-1.2
16、确认系统启动的时候会启动imap、imaps、spamd、http