当前位置:Linux教程 - Linux资讯 - qmail安装历程

qmail安装历程

  作者:webmaster      最近公司要开展虚拟主机业务,需要在一台mail服务器上绑定多个域名,于是呢,就想到qmail这位老人家了,照ideal的方法有点问题,就只好去看老外的life with qmail了,hehe   现在大约讲讲我的安装过程:   如果系统运行着sendmail就要把sendmail的守护进程杀掉,然后抓了qmail1.03.tar.gz,UCspi-tcp-0.88.tar.gz,daemontools-0.70.tar.gz这三个包,把他们扔/usr/local/src下面解压开,然后要建一些必要的目录   cd qmail-1.03   mkdir /var/qmail   ln -s /usr/man /var/qmail/man   mkdir /etc/qmail   ln -s /etc/qmail /var/qmail/control   ln -s /usr/sbin /var/qmail/bin   接着建安装qmail需要的组和用户:   groupadd nofiles   useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent   useradd qmaild -g nofiles -d /var/qmail -s /nonexistent   useradd qmaill -g nofiles -d /var/qmail -s /nonexistent   useradd qmailp -g nofiles -d /var/qmail -s /nonexistent   groupadd qmail   useradd qmailq -g qmail -d /var/qmail -s /nonexistent   useradd qmailr -g qmail -d /var/qmail -s /nonexistent   useradd qmails -g qmail -d /var/qmail -s /nonexistent   然后开始编译qmail:   make setup check   接着就配置域名了(这个需要你的机器域名能在dns上找到):   ./config(如果确定域名没错,也可以用./config-fast hostname.domainname)   然后要编译ucspi-tcp:   进入刚才ucspi-tcp解开的目录,执行:   make   make setup check   接着编译daemontools,也是进入解压的目录,执行   make   make setup check   下来就开始写一些qmail执行必须的脚本了,先是   vi /var/qmail/rc   脚本内容是:   #!/bin/sh     # Using stdout for logging   # Using control/defaultdelivery from qmail-local to deliver messages by default     exec env - PATH="/var/qmail/bin:$PATH"   qmail-start "`cat /var/qmail/control/defaultdelivery`"   最后   chmod 755 /var/qmail/rc   echo ./Maildir/ >/var/qmail/control/defaultdelivery(我用的是Maildir)   然后就是log文件了:   mkdir /var/log/qmail   mkdir -p /var/qmail/supervise/qmail-send/log   mkdir -p /var/qmail/supervise/qmail-smtpd/log   chmod +t /var/qmail/supervise/qmail-send   chmod +t /var/qmail/supervise/qmail-smtpd   建立/var/qmail/supervise/qmail-send/run文件,内容为:   #!/bin/sh   exec /var/qmail/rc   建立/var/qmail/supervise/qmail-send/log/run文件,内容为:   #!/bin/sh   exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail   建立/var/qmail/supervise/qmail-smtpd/run文件,内容:   #!/bin/sh   QMAILDUID=`id -u qmaild`   NOFILESGID=`id -g qmaild`   MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`   exec /usr/local/bin/softlimit -m 2000000   /usr/local/bin/tcpserver -v -p -x /etc/tcp.smtp.cdb   -c "$MAXSMTPD" -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1   建立/var/qmail/supervise/qmail-smtpd/log/run文件,内容:   #!/bin/sh   exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd   把以上四个run文件chmod 755   然后执行:   echo 20 > /var/qmail/control/concurrencyincoming   chmod 644 /var/qmail/control/concurrencyincoming   来建立qmail必须的concurrencyincoming文件   同时建立标准的log目录:   mkdir -p /var/log/qmail/smtpd   chown qmaill /var/log/qmail /var/log/qmail/smtpd   最关键的一步是建立qmail控制脚本,建立/etc/rc.d/init.d/qmail这个文件,内容:   脚本的HELP那块有些折行,尽量把他们弄一行.   #!/bin/sh     PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin   eXPort PATH     case "$1" in   start)   echo -n "Starting qmail: svscan"   cd /var/qmail/supervise   env - PATH="$PATH" svscan &   echo $! > /var/run/svscan.pid   echo "."   ;;   stop)   echo -n "Stopping qmail: svscan"   kill `cat /var/run/svscan.pid`   echo -n " qmail"   svc -dx /var/qmail/supervise/*   echo -n " logging"   svc -dx /var/qmail/supervise/*/log   echo "."   ;;   stat)   cd /var/qmail/supervise   svstat * */log   ;;   doqueuealrm)   echo "Sending ALRM signal to qmail-send."   svc -a /var/qmail/supervise/qmail-send   ;;   queue)   qmail-qstat   qmail-qread   ;;   reloadhup)   echo "Sending HUP signal to qmail-send."   svc -h /var/qmail/supervise/qmail-send   ;;   pause)   echo "Pausing qmail-send"   svc -p /var/qmail/supervise/qmail-send   echo "Pausing qmail-smtpd"   svc -p /var/qmail/supervise/qmail-smtpd   ;;   cont)   echo "Continuing qmail-send"   svc -c /var/qmail/supervise/qmail-send   echo "Continuing qmail-smtpd"   svc -c /var/qmail/supervise/qmail-smtpd   ;;   restart)   echo "Restarting qmail:"   echo "* Stopping qmail-smtpd."   svc -d /var/qmail/supervise/qmail-smtpd   echo "* Sending qmail-send SIGTERM and restarting."   svc -t /var/qmail/supervise/qmail-send   echo "* Restarting qmail-smtpd."   svc -u /var/qmail/supervise/qmail-smtpd   ;;   cdb)   tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp   chmod 644 /etc/tcp.smtp*   echo "Reloaded /etc/tcp.smtp."   ;;   help)   cat < stop -- stops mail service (smtp connections refused, nothing goesout)   start -- starts mail service (smtp connection accepted, mail cangoout)   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 -- sends qmail-send ALRM, scheduling queued messages fordelivery   reload -- sends qmail-send HUP, rereading locals and virtualdomains   queue -- shows status of queue   alrm -- same as doqueue   hup -- same as reload   HELP   ;;   *)   echo "Usage: $0 {startstoprestartdoqueuereloadstatpausecontcdbqueuehelp}"   exit 1   ;;   esac     exit 0   然后建立软连接让各个启动级别能不同的需要使用qmail控制脚本   ln -s qmail /etc/rc.d/rc0.d/K30qmail   ln -s qmail /etc/rc.d/rc1.d/K30qmail   ln -s qmail /etc/rc.d/rc2.d/S80qmail   ln -s qmail /etc/rc.d/rc3.d/S80qmail   ln -s qmail /etc/rc.d/rc4.d/S80qmail   ln -s qmail /etc/rc.d/rc5.d/S80qmail   ln -s qmail /etc/rc.d/rc6.d/K30qmail   然后就要建立qmail的访问控制文件了,执行   echo '127.:allow,RELAYCLIENT=""' >>/etc/tcp.smtp   /etc/rc.d/init.d/qmail cdb   如果不要旧的sendmail就用rpm -e --nodeps sendmail反安装吧。   然后用qmail的一些库文件替换掉旧的sendmail:   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   ln -s /var/qmail/bin/sendmail /usr/sbin   接着建立系统的一些alias(比如我要用grind来起qmail):   echo grind > /var/qmail/alias/.qmail-root   echo grind > /var/qmail/alias/.qmail-postmaster   ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon   chmod 644 /var/qmail/alias/.qmail-root   chmod 644 /var/qmail/alias/.qmailpostmaster   最后就能用/etc/rc.d/init.d/qmail start来启动qmail了。   接下去的绑定多域名就靠vpopmail来了,vpopmail能实现系统用户和邮件用户的分离,安装过程如下:   先建立vpopmail的用户和组:   groupadd vchkpw   useradd -g vchkpw vpopmail -d /home/vpopmail   然后建立访问控制文件:   设
[1] [2] 下一页 

(出处:http://www.sheup.com)


上一页 [1] [2]