1、安装qmail说明文档 制作者:赵艳静 2011-8-26目录系统类型1准备安装环境1基本环境1检查系统组件1准备软件包1检查编译环境2停用sendmail(或postfix)2创建qmail账户2创建qmail相关目录3目录结构3创建目录3安装qmail4安装 ucspi-tcp5安装 daemontools6安装 vpopmail7添加supervise 运行脚本9创建测试账户13创建域13验证域14添加账户14验证用户14发信测试14系统发信14验证收信15查看日志16系统类型Linux 64位准备安装环境基本环境:jpegsrc gd-2 gmp-4 libtool-1 libmcry
2、pt-2 libpng-1 mhash-0 openssl-0 nginx-0 pcre-7 mrtg-2检查系统组件:rpm qa | grep httpd; rpm qa | grep php; rpm qa | grep mysqld;如果上述命令返回结果为空,需要安装httpd-2.2.17.tar.gz mysql-5.1.56.tar.gz php-5.2.17.tar.gz准备软件包netqmail-1.05.tar.gz # qmail软件包,是打过各种补丁以后的完整包,不建议直接使用qmail-1.03.tar.gz daemontools-0.70.tar.gz # 管理服
3、务进程ucspi-tcp-0.88.tar.gz# 创建和接受TCP连接vpopmail-3_4_11-2_released_tar.gz# 支持虚拟域ezmlm-0_53_tar.gz # 管理邮件列表autorespond-1_0_0_tar.gz# 自动回复功能qmailadmin-0.30pre1.tar.gz# web控制接口检查编译环境# ccNo input files specified #如果返回上述结果,说明缺省搜索访问路径上有可用的C编译器,如果没有返回结果,则继续执行以下几个命令:/usr/bin/cc /usr/bin/gcc /usr/local/bin/cc /u
4、sr/local/bin/gcc /usr/ccs/bin/cc 如果上述命令均没有返回结果,则需要检查安装包,并安装对于 Red Hat Linux, 使用: rpm -qa | grep gcc 或者 rpm -qa | grep egcs 对于 FreeBSD: 默认安装已经包括了GCC编译器. 停用sendmail(或postfix)mv /usr/sbin/sendmail /usr/sbin/sendmail.bakln -s /var/qmail/bin/sendmail /usr/sbin/sendmail创建qmail账户alias qmaild qmaill qmailp
5、属于nofiles组;qmailq qmailr qmails属于qmail组;vchkpw属于vchkpw组groupadd -g 801 qmailgroupadd -g 802 nofilesgroupadd -g 808 vchkpw useradd -g nofiles -d /var/qmail/alias -s /sbin/nologin -p* -u 800 aliasuseradd -g nofiles -d /var/qmail -M -s /sbin/nologin -p* -u 801 qmailduseradd -g nofiles -d /var/qmail -M
6、-s /sbin/nologin -p* -u 802 qmailluseradd -g nofiles -d /var/qmail -M -s /sbin/nologin -p* -u 803 qmailpuseradd -g qmail -d /var/qmail -M -s /sbin/nologin -p* -u 804 qmailquseradd -g qmail -d /var/qmail -M -s /sbin/nologin -p* -u 805 qmailruseradd -g qmail -d /var/qmail -M -s /sbin/nologin -p* -u 80
7、6 qmailsuseradd -g vchkpw -d /home/vpopmail -s /nonexistent -u 808-c Vpopmail-Master创建qmail相关目录目录结构# ls /var/log/qmail/qmail-imapd qmail-pop3d qmail-send qmail-smtpd# ls /var/qmail/supervise/qmail-imapd qmail-monitor qmail-pop3d qmail-send qmail-smtpd创建目录mkdir -p /var/qmail; chown -R root:qmail /var
8、/qmailmkdir -p /var/log/qmail mkdir -p /var/log/qmail/qmail-sendmkdir -p /var/log/qmail/qmail-smtpd mkdir -p /var/log/qmail/qmail-pop3dmkdir -p /var/log/qmail/qmail-imapdchown -R qmaill:root /var/log/qmailchmod -R 750 /var/log/qmailmkdir -p /var/qmail/supervisemkdir -p /var/qmail/supervise/qmail-smt
9、pd mkdir -p /var/qmail/supervise/qmail-smtpd/logchmod +t /var/qmail/supervise/qmail-smtpdmkdir -p /var/qmail/supervise/qmail-sendmkdir -p /var/qmail/supervise/qmail-send/logchmod +t /var/qmail/supervise/qmail-sendmkdir -p /var/qmail/supervise/qmail-pop3dmkdir -p /var/qmail/supervise/qmail-pop3d/logc
10、hmod +t /var/qmail/supervise/qmail-pop3dmkdir -p /var/qmail/supervise/qmail-imapdmkdir -p /var/qmail/supervise/qmail-imapd/logchmod +t /var/qmail/supervise/qmail-imapdmkdir -p /var/qmail/supervise/qmail-monitor安装qmail当前目录/usr/local/src/qmailtar xf netqmail-1.05.tarcd netqmail-1.05.tar./collate.sh #上
11、述命令的主要功能是自动解压并打上补丁,产生一个netqmail-1.05目录 #生成了目录/usr/local/src/qmail/netqmail-1.05/netqmail-1.05netqmail-1.05执行上述命令的时候需要注意是否报错信息,一般正确的返回信息是:You should see 7 lines of text below. If you see anything else, then something might be wrong. 1 Extracting qmail-1.03. 2 Patching qmail-1.03 into netqmail-1.05. L
12、ook for errors below: 4 The previous line should say 24 if you used GNU patch. 5 Renaming qmail-1.03 to netqmail-1.05. 6 Continue installing qmail using the instructions found at: 7 http:/www.lifewithqmail.org/lwq.html#installation#上述命令所作的操作是:解压/usr/local/src/qmail/netqmail-1.05/qmail-1.03.tar.gz到当前
13、目录然后进入/usr/local/src/qmail/netqmail-1.05/qmail-1.03打补丁netqmail-1.05.patchcd /usr/local/src/qmail/netqmail-1.05/netqmail-1.05netqmail-1.05make setup check 可能会出现如下报错:./compile auto-uid.cauto-uid.c: In function ?.ain?.auto-uid.c:22: warning: return type of ?.ain?.is not ?.nt?./load auto-uid substdio.a
14、error.a str.a fs.a ./compile auto-gid.cauto-gid.c: In function ?.ain?.auto-gid.c:22: warning: return type of ?.ain?.is not ?.nt?./load auto-gid substdio.a error.a str.a fs.a ( ./auto-uid auto_uida head -1 conf-users &./auto-uid auto_uidd head -2 conf-users | tail -1 &./auto-uid auto_uidl head -3 con
15、f-users | tail -1 &./auto-uid auto_uido head -4 conf-users | tail -1 &./auto-uid auto_uidp head -5 conf-users | tail -1 &./auto-uid auto_uidq head -6 conf-users | tail -1 &./auto-uid auto_uidr head -7 conf-users | tail -1 &./auto-uid auto_uids head -8 conf-users | tail -1 &./auto-gid auto_gidq head
16、-1 conf-groups &./auto-gid auto_gidn head -2 conf-groups | tail -1 ) auto_uids.c.tmp & mv auto_uids.c.tmp auto_uids.cfatal: unable to find user rootmake: * auto_uids.c Error 111如果“make setup check”命令执行成功的话,最后两行是如下提示:./install./instcheck# ./config 查看DNS配置情况Your hostname is xkwb5705. #主机名Your hosts fu
17、lly qualified name in DNS is bt-199-. # 在DNS解析中完整的主机名是bt-199-Putting bt-199- into control/me. #将完整主机名加入控制文件me Putting into control/defaultdomain. #将完整主机名加入控制文件defaultdomainPutting into control/plusdomain. #将完整主机名加入控制文件plusdomain Checking local IP addresses: #检测本地IP地址0.0.0.0: PTR lookup failed. I a
18、ssume this address has no DNS name. #反向解析失败127.0.0.1: Adding localhost to control/locals. #将被地循环地址加入控制文件locals202.106.195.30: Adding to control/locals.211.100.97.250: PTR lookup failed. I assume this address has no DNS name. #本机没有设置反向解析 If there are any other domain names that point to you,you will
19、 have to add them to /var/qmail/control/locals.You dont have to worry about aliases, i.e., domains with CNAME records. Copying /var/qmail/control/locals to /var/qmail/control/rcpthosts.Now qmail will refuse to accept SMTP messages except to those hosts.Make sure to change rcpthosts if you add hosts
20、to locals or virtualdomains!安装 ucspi-tcp#tar zxf ucspi-tcp-0.88-last.tar.gz #cd ucspi-tcp-0.88#make在没有打补丁的情况下直接编译会有如下的错误提示:/lib64/libc.so.6: could not read symbols: Bad valuecollect2: ld returned 1 exit statusmake: * tcpserver Error 1现在来打补丁# patch /usr/local/src/qmail/netqmail-1.05/other-patches/ucs
21、pi-tcp-0.88.errno.patch patching file error.h# make# make setup check./install./instcheckucspi-tcp安装完毕安装 daemontools# mkdir /package# tar zxf daemontools-0.76.tar.gz -C /package/#cd /package/admin/daemontools-0.76/# cd src/# patch daemontools-0.76.Making command links in /command.Making compatibilit
22、y links in /usr/local/bin./service exists. I assume that svscan is already running.下面查看一下创建的链接# ll /command/ |awk print $9 $10 $11|sed 1denvdir - /package/admin/daemontools/command/envdirenvuidgid - /package/admin/daemontools/command/envuidgidfghack - /package/admin/daemontools/command/fghackmultilo
23、g - /package/admin/daemontools/command/multilogpgrphack - /package/admin/daemontools/command/pgrphackreadproctitle - /package/admin/daemontools/command/readproctitlesetlock - /package/admin/daemontools/command/setlocksetuidgid - /package/admin/daemontools/command/setuidgidsoftlimit - /package/admin/
24、daemontools/command/softlimitsupervise - /package/admin/daemontools/command/supervisesvc - /package/admin/daemontools/command/svcsvok - /package/admin/daemontools/command/svoksvscan - /package/admin/daemontools/command/svscansvscanboot - /package/admin/daemontools/command/svscanbootsvstat - /package
25、/admin/daemontools/command/svstattai64n - /package/admin/daemontools/command/tai64ntai64nlocal - /package/admin/daemontools/command/tai64nlocal再查看一下svscan进程是否已经运行# ps -ef |grep svscan或# ps -aux |grep svscan如果没有运行的话,作如下操作# vi/etc/inittab 【添加下行】SV:123456:respawn:/command/svscanboot如果可以的话,需要reboot重启机器,
26、重启之后在查看svscan进程,已经启动# ps -ef |grep svscan |grep -v grep root 4088 1 0 16:35 ? 00:00:00 /bin/sh /command/svscanbootroot 4119 4088 0 16:35 ? 00:00:00 svscan /service安装 vpopmailif .$vpopmaildir = . then vpopmaildir=/home/vpopmailfi mkdir -p $vpopmaildir/etcecho 127.0.0.1:allow,RELAYCLIENT= $vpopmaildir
27、/etc/tcp.smtpecho :allow $vpopmaildir/etc/tcp.smtptar zxf vpopmail-5.4.33.tar.gzcd vpopmail-5.4.33./configure 可能有如下错误提示echo Install Vpopmail 5.4.20checking whether password file entry for the vpopmail user exists. No vpopmail user found.Please add the vchkpw group andvpopmail user. Then run configur
28、e againnoconfigure: error: Could not compile and run even a trivial ANSI C program - check CC.出现上述错误原因很可能是没有创建用户vchkpw和组vchkpw# groupadd vchkpw -g 808# useradd vpopmail -u 808 -g 808 -c Vpopmail-Master -d /home/vpopmail/ -s /nonexistent再次编译一下,编译成功,显示如下vpopmail当前的配置信息 vpopmail 5.4.33 Current settings
29、-vpopmail directory = /home/vpopmail/ domains directory = /home/vpopmail/domains uid = 808 gid = 808 roaming users = OFF -disable-roaming-users (default) password learning = OFF -disable-learn-passwords (default) md5 passwords = ON -enable-md5-passwords (default) file locking = ON -enable-file-locki
30、ng (default)vdelivermail fsync = OFF -disable-file-sync (default) make seekable = ON -enable-make-seekable (default) clear passwd = ON -enable-clear-passwd (default) user dir hashing = ON -enable-users-big-dir (default)address extensions = OFF -disable-qmail-ext (default) ip alias = OFF -disable-ip-
31、alias-domains (default) onchange script = OFF -disable-onchange-script (default) domain quotas = OFF -disable-domainquotas (default) auth module = cdb -enable-auth-module=cdb (default) auth inc = -Icdb auth lib = system passwords = OFF -disable-passwd (default) pop syslog = show only failed attempts
32、 -enable-logging=e (default) auth logging = ON -enable-auth-logging (default) spamassassin = OFF -disable-spamassassin (default) maildrop = OFF -disable-maildrop (default)# make上述命令执行成功的话,会返回如下信息:make2: Leaving directory /usr/local/src/qmail/vpopmail-5.4.33make1: Leaving directory /usr/local/src/qma
33、il/vpopmail-5.4.33# echo #define DOMAIN_QUOTAS 1 config.h# make install-strip上述命令执行成功的话,会返回如下信息:make3: Leaving directory /usr/local/src/qmail/vpopmail-5.4.33make2: Leaving directory /usr/local/src/qmail/vpopmail-5.4.33* If you plan to use the vpopmail usage daemon run the following commands: cd vusa
34、ged & ./configure & make Then follow the INSTALL file to install*make1: Leaving directory /usr/local/src/qmail/vpopmail-5.4.33# chown -R vpopmail /home/vpopmail/bin/vchkpw # chmod 755 /home/vpopmail/bin/vchkpw # ls -l /home/vpopmail/bin/vchkpw -rwxr-xr-x 1 vpopmail vchkpw 128200 Aug 25 16:56 /home/v
35、popmail/bin/vchkpwVpopmail安装完成添加supervise 运行脚本编辑/var/qmail/rc#!/bin/sh# Using splogger to send the log through syslog.# Using qmail-local to deliver messages to /Mailbox by default.exec env - PATH=/var/qmail/bin:$PATH qmail-start ./Maildir 如果写成exec env - PATH=/Var/qmail/bin:$PATH qmail-start ./Mailb
36、ox splogger qmail那么qmail发送日志将记录在maillog-使用如下脚本给run文件添加执行命令:#!/bin/shecho create /var/qmail/supervise/qmail-pop3d/runecho #!/bin/sh /var/qmail/supervise/qmail-pop3d/runecho exec /usr/local/bin/tcpserver -H -R -v -c100 0 110 /var/qmail/bin/qmail-popup /var/qmail/supervise/qmail-pop3d/runecho /home/vp
37、opmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2&1 /var/qmail/supervise/qmail-pop3d/runchmod 751 /var/qmail/supervise/qmail-pop3d/runecho create /var/qmail/supervise/qmail-pop3d/log/runecho #!/bin/sh /var/qmail/supervise/qmail-pop3d/log/runecho exec /usr/local/bin/setuidgid qmaill /usr/local/b
38、in/multilog t s10000000 n20 /var/log/qmail/qmail-pop3d 2&1 /var/qmail/supervise/qmail-pop3d/log/runchmod 751 /var/qmail/supervise/qmail-pop3d/log/runecho create /var/qmail/supervise/qmail-smtpd/runecho #!/bin/sh /var/qmail/supervise/qmail-smtpd/runecho exec /usr/local/bin/tcpserver -h -p -R -u808 -g
39、808 -v -c500 0 smtp /usr/local/bin/rblsmtpd /var/qmail/bin/qmail-smtpd /home/vpopmail/bin/vchkpw /usr/bin/true 2&1/var/qmail/supervise/qmail-smtpd/runchmod 751 /var/qmail/supervise/qmail-smtpd/runecho create /var/qmail/supervise/qmail-smtpd/log/runecho #!/bin/sh /var/qmail/supervise/qmail-smtpd/log/
40、runecho exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n20 /var/log/qmail/qmail-smtpd 2&1 /var/qmail/supervise/qmail-smtpd/log/runchmod 751 /var/qmail/supervise/qmail-smtpd/log/runecho create /var/qmail/supervise/qmail-send/runecho #!/bin/sh /var/qmail/supervise/qmail-send/
41、runecho exec /var/qmail/rc /var/qmail/supervise/qmail-send/runchmod 751 /var/qmail/supervise/qmail-send/runecho create /var/qmail/supervise/qmail-send/log/runecho #!/bin/sh /var/qmail/supervise/qmail-send/log/runecho exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n20 /var/l
42、og/qmail/qmail-send 2&1 /var/qmail/supervise/qmail-send/log/runchmod 751 /var/qmail/supervise/qmail-send/log/run echo create /var/qmail/supervise/qmail-imapd/runecho #!/bin/sh /var/qmail/supervise/qmail-imapd/runecho exec 2&1 /var/qmail/supervise/qmail-imapd/runecho /usr/local/bin/tcpserver -H -R -v -c100 -l $(hostname) 0 143 /usr/local/etc/bincimap-config /usr/local/bin/bincimap-up - /home/vpopmail/bin/vchkpw /usr/local/bin/bincimapd Maildir /var/qmail/supervise/qmail-imapd/runchmod 751 /var/qmail/supervise/qmail-imapd/runecho create /var/qmail/supervise/qma