一、准備工作: 安裝gcc、make、autoconf、automake等編譯工具,建立網絡連接,配置域名。
二、安裝patch工具: # gzip –d patch-2.5.4-sol8-intel-local.gz # pkgadd –d patch-2.5.4-sol8-intel-local # mv /usr/bin/patch /usr/bin/patch.bak # cp /usr/local/bin/patch /usr/bin/patch
三、安裝UCspi-tcp-0.88 # gzip -d ucspi-tcp-0.88.tar.gz # tar xvf ucspi-tcp-0.88.tar # cd ucspi-tcp-0.88 # patch -p1 < ../ucspi-tcp-0.88.a_record.patch # patch -p1 < ../ucspi-tcp-0.88.errno.patch # patch -p1 < ../ucspi-tcp-0.88.nobase.patch # make # make setup check
四、安裝qmail 1.建目錄: # mkdir /var/qmail # mkdir /var/qmail/alias 2.建組及用戶: # groupadd nofiles # groupadd qmail # useradd -g nofiles -m -d /var/qmail/alias -s /bin/false alias # useradd -g nofiles -m -d /var/qmail -s /bin/false qmaild # useradd -g nofiles -m -d /var/qmail -s /bin/false qmaill # useradd -g nofiles -m -d /var/qmail -s /bin/false qmailp # useradd -g qmail -m -d /var/qmail -s /bin/false qmailq # useradd -g qmail -m -d /var/qmail -s /bin/false qmailr # useradd -g qmail -m -d /var/qmail -s /bin/false qmails 3.打補丁及編繹安裝qmail # gzip -d qmail-1.03.tar.gz # tar xvf qmail-1.03.tar # gzip -d qmail-smtpd-auth-0.31.tar.gz # tar xvf qmail-smtpd-auth-0.31.tar # cp qmail-smtpd-auth-0.31/base64.* qmail-1.03 # patch -d qmail-1.03 < qmail-smtpd-auth-0.31/auth.patch # cd qmail-1.03 # patch -p1 < ../qmail-103.patch # patch -p1 < ../qmailqueue-patch # patch -p1 < ../qmail-1.03.qmail_local.patch # patch -p1 < ../qmail-maildir++.patch # patch -p1 < ../qmail-1.03.errno.patch 修改qmail-smtpd.c將函數straynewline中的451改為553.(在53行) 查找“http://”兩次,改其中的url如下(這樣可以使QMAIL更安全些): void straynewline() { out("451 See http://Nero.3322.org.\r\n"); out("214 llzQQ home page: http://nero.3322.org\r\n"); # make setup check 出現錯誤後,修改auto-ccld.sh文件中CC,LD成你所用的環境就可以了。 # ./config-fast nero.3322.org 4.添加別名用戶: # touch /var/qmail/alias/.qmail-root # touch /var/qmail/alias/.qmail-postmaster # touch /var/qmail/alias/.qmail-mailer-daemon 5.如果存在postfix和sendmail,停用現在的mail服務 # ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail # chmod 777 /usr/sbin/sendmail
五、安裝vpopmail 1.建立目錄: # mkdir /eXPort/home/vpopmail # mkdir /export/home/vpopmail/etc 2.添加用戶和組: # groupadd vchkpw # useradd -g vchkpw -s /bin/false -m -d /export/home/vpopmail vpopmail 3.添加mysql的vpopmail用戶,用於操作vpopmail數據庫 # mysql -u root –p****** mysql>create database vpopmail; mysql>grant all on vpopmail.* to vpopmail@localhost identified by "passWord"; 4.編譯安裝vpopmail # gzip -d vpopmail-5.2.1.tar.gz # tar xvf vpopmail-5.2.1.tar # cd vpopmail-5.2.1 # vi vmysql.h ========================= vmysql.h======================== #define MYSQL_UPDATE_SERVER "localhost" (mysql服務器名) #define MYSQL_UPDATE_USER "vpopmail" (用戶名) #define MYSQL_UPDATE_PASSWD "*****" (改成你設置的密碼) #define MYSQL_READ_SERVER "localhost" (mysql服務器名) #define MYSQL_READ_USER "vpopmail" (用戶名) #define MYSQL_READ_PASSWD "*****" (改成你設置的密碼) 在54行和58行後加 \ #define TABLE_LAYOUT "pw_name char(32) not null, \ pw_domain char(64) not null, <===== 54 pw_passwd char(40), \ pw_uid int, pw_gid int, \ pw_gecos char(4, \ pw_dir char(160), <===== 58 pw_shell char(20), \ primary key (pw_name, pw_domain ) " ========================= vmysql.h======================== 5.創建tcp.smtp文件(或者使用/etc/tcp.smtp) # vi /export/home/vpopmail/etc/tcp.smtp 127.0.0.1:allow,RELAYCLIENT="" :allow # cd /export/home/vpopmail/etc # tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp 6.進行編譯: ./configure --prefix=/export/home/vpopmail --enable-mysql=y --enable-incdir=/opt/sfw/mysql/include/mysql --enable-libdir=/opt/sfw/mysql/lib/mysql --enable-default-domain=nero.3322.org --enable-passwd=n --enable-defaultquota=52428800s --enable-tcprules-prog=/usr/local/bin/tcprules --enable-tcpserver-file=/export/home/vpopmail/etc/tcp.smtp --enable-vpopuser=vpopmail --enable-vpopgroup=vchkpw --enable-ip-alias-domains=n 需要改下面兩個文件中的“cc -s”為“gcc -s” ./cdb/conf-cc ./cdb/conf-ld # make # make install-strip 7.創建虛擬域 # cd /export/home/vpopmail/bin # ./vadddomain nero.3322.org 如果不成功的話,則必須先刪除創建的域(vdeldomain 域名), # ./vadduser
[email protected] # ./vadduser
[email protected] 如果添加domain時,提示Domain already exists,但卻刪除domain又提示Domain does not exist.則采用下面的處理方法. 刪除/var/qmail/control目錄下rcpthosts,virtualdomains文件中有關domain的信息;同時刪除/var/qmail/user目錄下assign文件中有關domain的信息;然後運行/var/qmail/bin/qmail-newu.這時候就可以正常添加domain了.
六、smtp-auth的設置 1.修改vchkpw的屬性 # cd /export/home/vpopmail/bin # chmod 4755 vchkpw # chown root:sys vchkpw 如果使用帶驗證的smtp,smtp進程要調用密碼驗證程序,則必須要使用 setuid 和setgid。提高vchkpw的權限,才能完成setgid操作。 2.安裝cmd5checkpw # gzip -d cmd5checkpw-0.22.tar.gz # tar xvf cmd5checkpw-0.22.tar # cd cmd5checkpw-0.22 # make # mkdir /usr/man/man8 # make install
七、生成qmail的啟動腳本 # cp /var/qmail/boot/home /var/qmail/rc 對rc文件進行修改,以決定投送方式: # vi /var/qmail/rc 這裡要注意,這三個文件中的命令最好寫在一行. =====================================rc===================================== #!/bin/sh # Using splogger to send the log through syslog. # Using dot-forward to support sendmail-style ~/.forward files. # Using qmail-local to deliver messages to ~/Mailbox by default. exec env - PATH="/var/qmail/bin:$PATH" qmail-start ./Maildir/ splogger qmail & =====================================rc===================================== 編輯smtp服務的啟動腳本 # vi /var/qmail/smtp ====================================smtp==================================== #!/bin/sh QMAILDUID=qmaild NOFILESGID=nofiles /usr/local/bin/tcpserver -H -R -l 0 -t 1 -v -p -x /export/home/vpopmail/etc/tcp.smtp.cdb -u $QMAILDUID -g $NOFILESGID 0 smtp /var/qmail/bin/qmail-smtpd nero.3322.org /export/home/vpopmail/bin/vchkpw /bin/true /bin/cmd5checkpw /bin/true 2>&1 /var/qmail/bin/splogger smtpd 3 & ====================================smtp==================================== 編輯pop3服務的啟動腳本 # vi /var/qmail/pop3 ====================================pop3==================================== #!/bin/sh /usr/local/bin/tcpserver -H -R 0 pop3 /var/qmail/bin/qmail-popup nero.3322.org /export/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir & ====================================