|
这是去年我装qmail时所写的文档,应该没有什么问题。
关于qmail的安装
系统平台:
Redhat Linux 7.1
所需软件包:
qmail-1.03.tar.gz
ucspi-tcp-0.88.tar.gz
daemontools-0.76.tar.gz
checkpassword-0.90.tar.gz
vpopmail-5.0.1.tar.gz
ezmlm-0.53.tar.gz
autorespond-2.0.2.tar.gz
qmailadmin-1.0.1.tar.gz
sqwebmail-3.3.1.tar.gz
vqsignup-0.5.tar.gz
安装步骤:
1.安装qmail
i安装前的准备工作
准备安装目录
#mkdir /var/qmail
建立qmail的用户和组
On Solaris and Linux:
# groupadd nofiles
# useradd -g nofiles -d /var/qmail/alias alias
# useradd -g nofiles -d /var/qmail qmaild
# useradd -g nofiles -d /var/qmail qmaill
# useradd -g nofiles -d /var/qmail qmailp
# groupadd qmail
# useradd -g qmail -d /var/qmail qmailq
# useradd -g qmail -d /var/qmail qmailr
# useradd -g qmail -d /var/qmail qmails
On FreeBSD 2.2:
# pw groupadd nofiles
# pw useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent
# pw useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
# pw useradd qmaill -g nofiles -d /var/qmail -s /nonexistent
# pw useradd qmailp -g nofiles -d /var/qmail -s /nonexistent
# pw groupadd qmail
# pw useradd qmailq -g qmail -d /var/qmail -s /nonexistent
# pw useradd qmailr -g qmail -d /var/qmail -s /nonexistent
# pw useradd qmails -g qmail -d /var/qmail -s /nonexistent
On AIX:
# mkgroup -A nofiles
# mkuser pgrp=nofiles home=/var/qmail/alias shell=/bin/true alias
# mkuser pgrp=nofiles home=/var/qmail shell=/bin/true qmaild
# mkuser pgrp=nofiles home=/var/qmail shell=/bin/true qmaill
# mkuser pgrp=nofiles home=/var/qmail shell=/bin/true qmailp
# mkgroup -A qmail
# mkuser pgrp=qmail home=/var/qmail shell=/bin/true qmailq
# mkuser pgrp=qmail home=/var/qmail shell=/bin/true qmailr
# mkuser pgrp=qmail home=/var/qmail shell=/bin/true qmails
安装:
#cp qmail-1.03.tar.gz /usr/local/src
#tar –zxvf qmail-1.03.tar.gz
#cd qmail-1.03
#make setup check
#./config (如果主机名不在DNS中,运行#./config-fast hostname
建立邮件别名
#cd /var/qmail/alias
#touch .qmail-postmaster .qmail-mailer-daemon .qmail-root
#chmod 644 .qmail*
#echo ‘root’ > .qmail*
建立qmail启动文件并设置用户的Maildir
#cp /var/qmail/boot/home /var/qmail/rc
#chmod 755 /var/qmail/rc
#vi /var/qmail/rc
将./Mailbox改为./Maildir/
建立本用户的Maildir
/var/qmail/bin/maildirmake
echo ./Maildir/ >~/.qmail
chmod 700 ~/Maildir
为以后新建用户设置Maildir
/var/qmail/bin/maildirmake /etc/skel/Maildir
echo ./Maildir/>~/.qmail
安装ucspi-tcp
#cp ucspi-tcp-0.88.tar.gz /usr/local/src
#tar –zxvf ucspi-tcp-0.88.tar.gz
#cd /usr/local/src/ucspi-tcp-0.88
#make
#make setup check
安装daemontools
#mkdir –p /package
#chmod 1755 /package
#cp daemontools-0.76.tar.gz /package
#tar –zxvf daemontools-0.76.tar.gz
#cd daemontools-0.76
#/package/install
安装checkpassword
checkpassword 主要用于对/etc/passwd中的用户开放mail,如果采用虚拟域名则只需装vpopmail即可。
安装vpopmail
#groupadd vchkpw
#useradd –g vchkpw vpopmail
#mkdir ~vpopmail/etc
#echo “:allow” > ~vpopmail/etc/tcp.smtp
#./configure –enable-roaming-users=y –enable-default-domain=domain.com –enable-passwd=n (详细配置参考INSTALL文件或打./configure –help)
#make
#make install-strip
#crontab –e
40 * * * * /home/vpopmail/bin/clearopensmtp 2>&1 > /dev/null
#cd /home/vpopmail/bin
用vadddomain,vaddusers来添加虚拟域和虚拟用户。
删除所有sendmail文件和进程(尤其是进程,一定要删除,否则将占据端口)
建立系统别名
#cd /var/qmail/alias
#touch .qmail-postmaster .qmail-daemon .qmail-root
#chmod 644 .qmail*
#echo ‘root’ > .qmail*
建立Maildir
#cp /var/qmail/boot/home /var/qmail/rc
#chmod 755 /var/qmail/rc
#vi /var/qmail/rc
修改最后一行,将./Mailbox改为./Maildir/
#/var/qmail/bin/maildirmake /etc/skel/Maildir
#echo ./Maildir/ >~/.qmail
建立qmailctl脚本
#vi /var/qmail/bin/qmailctl
#!/bin/sh
# For Red Hat chkconfig
# chkconfig: - 80 30
# description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
case "$1" in
start)
echo "Starting qmail"
if svok /service/qmail-send ; then
svc -u /service/qmail-send
else
echo qmail-send supervise not running
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd
else
echo qmail-smtpd supervise not running
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
fi
if svok /service/qmail-pop3d ; then
svc -u /service/qmail-pop3d
else
echo qmail-pop3d supervise not running
fi
;;
stop)
echo "Stopping qmail..."
echo " qmail-smtpd"
svc -d /service/qmail-smtpd
echo " qmail-send"
svc -d /service/qmail-send
echo " qmail-pop3d"
svc -d /service/qmail-pop3d
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
svstat /service/qmail-pop3d
svstat /service/qmail-pop3d/log
qmail-qstat
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /service/qmail-send
;;
pause)
echo "ausing qmail-send"
svc -p /service/qmail-send
echo "ausing qmail-smtpd"
svc -p /service/qmail-smtpd
echo "ausing qmail-pop3d"
svc -p /service/qmail-pop3d
;;
cont)
echo "Continuing qmail-send"
svc -c /service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /service/qmail-smtpd
echo "Continuing qmail-pop3d"
svc -c /service/qmail-pop3d
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /service/qmail-smtpd
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /service/qmail-send
echo "* Restarting qmail-smtpd."
svc -u /service/qmail-smtpd
echo "* Restarting qmail-pop3d."
svc -u /service/qmail-pop3d
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat <<HELP
stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
exit 0
在启动目录中做好相应连接
ln -s /var/qmail/bin/qmailctl /etc/rc.d/init.d/qmail
ln -s ../init.d/qmail /etc/rc0.d/K30qmail
ln -s ../init.d/qmail /etc/rc1.d/K30qmail
ln -s ../init.d/qmail /etc/rc2.d/S80qmail
ln -s ../init.d/qmail /etc/rc3.d/S80qmail
ln -s ../init.d/qmail /etc/rc4.d/S80qmail
ln -s ../init.d/qmail /etc/rc5.d/S80qmail
ln -s ../init.d/qmail /etc/rc6.d/K30qmail
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
建立supervise脚本
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
vi /var/qmail/supervise/qmail-send/run
#!/bin/sh
exec /var/qmail/rc
vi /var/qmail/supervise/qmail-send/log/run
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail
vi /var/qmail/supervise/qmail-smtpd/run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" ]; then
echo QMAILDUID, NOFILESGID, or MAXSMTPD is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -l 0 -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
vi /var/qmail/supervise/qmail-smtpd/log/run
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd
vi /var/qmail/supervise/qmail-pop3d/run
#!/bin/sh
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -H -l 0 0 110 /var/qmail/bin/qmail-popup \
域名 /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1
Vi /var/qmail/supervise/qmail-pop3d/log/run
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t \
/var/log/qmail/pop3d
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
mkdir -p /var/log/qmail/smtpd
chown qmaill /var/log/qmail /var/log/qmail/smtpd
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service
vi /etc/tcp.smtp
“需要转发的IP地址”:allow,RELAYCLIENT=””
(用:allow则表示允许所有转发)
#qmailctl cdb
或#tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
#chmod 644 /etc/tcp.smtp*
qmailadmin的安装(Web方式管理qmail)
安装ezmlm
#make; make man; make setup
安装autorespond
#make; make install
安装qmailadmin
考虑几个条件:是否有vchkpw用户;cgi-bin目录位置,ezmlm目录和autorespond目录位置。
#./configure; make; make install-strip
http://mail.mydomain.com/cgi-bin/qmailadmin
Sqwebmail
#./configure -- without-authpam --without-authuserdb --enable-webpass=no /
--without-authpwd --without-authshadow
#make configure-check
#make
#make install-strip
#make install-configure
http://mail.mydomain.com/cgi-bin/sqwebmail |
|