歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux資訊 >> 更多Linux

QMAIL簡明安裝

  如果系統運行著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   然後建立訪問控制文件:   設置tcp.smtp文件   echo "127.0.0.:allow,RELAYCLIENT=""" > ~vpopmail/etc/tcp.smtp   接著用非root用戶解壓vpopmail的壓縮包:   $tar zxvf vpopmail-4.9.tar.gz   $cd vpopmail-4.9   $./configure --enable-default-domain=y




Copyright © Linux教程網 All Rights Reserved