qmail 1.03+courier+vpopmail+mysql+qmailadmin+webmail安装指南
对这个演示的补充说明-- qmail 1.03+courier+vpopmail+mysql安装指南
请到http://gujian.sege.com.cn/mail2000 去看这个文档的演示,用户名:hup
密码: 12345
作者:古剑
摘要: 本文对qmail用户实现mysql的数据库管理,同时实现多虚拟主域的邮件发送,支持pop3、imap,使系统能够实现千万级的用户负载,同时提供邮件用户的后台管理。在此基础上可以进一步实现webmail的收发,邮件列表的管理等等。以实现真正意义上的千万级用户支持和友好的用户接口的电子邮件系统。
硬件环境:x86兼容系统,内存128m,单网卡。建议qmail、mysql、webmail分别安装在单独(或者多台)的机器上,以便实现海量邮件用户支持。本系统也在sun solaris 8上通过。
软件准备:
red hat linux 7.0 内核2.2.16以上
mysql-3.23.38-1.src.rpm
qmail-1.03+patches-18.src.rpm
dot-forward-0.71.tar.gz
courier-imap-1.3.8.1.tar.gz
ucspi-tcp-0.88.tar.gz
vpopmail-4.10.21.tar.gz
apache_1.3.19.tar.gz
php-4.05.tar.gz
vqregister-2.5.tar.gz(在线帐号申请)
webmail1.0.tar.gz
autorespond-1.0.0.tar.gz
ezmlm-idx
qmailadmin-0.45.tar.gz
注意:本文没有讲vmailmgr的安装和配置,这里简单介绍它的安装中注意事项:
vmailmgr 0.96.9.tar.gz
对它./configure 后必须修改config.h文件加入#include和#include才可以编译成功!
mysql的安装:
解压和安装
#rpm –ivh ./ mysql-3.23.38-1.src.rpm
#mv /usr/src/redhat/sources/mysql-3.23.38.tar.gz /tmp
#cd /tmp
#tar –zxvf mysql-3.23.38.tar.gz
#cd mysql-3.23.38
#./configure
#make
#make install
#scripts/mysql_install_db
#/usr/local/bin/safe_mysqld& 有时候要重新启动系统才能正常启动mysql。
#mysqladmin –uroot password yourpassword
#/usr/local/bin/mysqladmin -u root -p password new-password
#/usr/local/bin/mysqladmin -u root -h gujian.sege.com.cn -p password new-passwor
d
#echo /usr/local/mysql/bin/safe_mysqld& >> /etc/rc.d/rc.local
在/etc/ld.so.conf文件末尾添加一行:
/usr/local/lib/mysql
#ldconfig
qmail的安装:
$ttl 86400
@ in soa gujian.sege.com.cn. gujian.gujian.sege.com.cn. (
1997022700 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ) ; minimum
in ns gujian.sege.com.cn.
in mx 10 gujian.sege.com.cn.
gujian in a 192.168.0.1
@ in a 192.168.0.1
$ttl 86400
@ in soa gujian.sege.com.cn. gujian.gujian.sege.com.cn. (
1997022700 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ) ; minimum
in ns gujian.sege.com.cn.
in mx 10 gujian.sege.com.cn.
mail in a 192.168.0.1
# rpm -e --nodeps sendmail
#mkdir /var/qmail
# groupadd -g 1000 nofiles
# useradd -u 5000 -g nofiles -d /var/qmail/alias alias
# useradd -u 5001 -g nofiles -d /var/qmail qmaild
# useradd -u 5002 -g nofiles -d /var/qmail qmaill
# useradd -u 5003 -g nofiles -d /var/qmail qmailp
# groupadd -g 1001 qmail
# useradd -u 5004 -g qmail -d /var/qmail qmailq
# useradd -u 5005 -g qmail -d /var/qmail qmailr
# useradd -u 5006 -g qmail -d /var/qmail qmails
#rpm –ivh qmail-1.03+patches-18.src.rpm
# mv /usr/src/redhat/sources/qmail-1.03.tar.gz /tmp
# mv /usr/src/redhat/sources/qmail-1.03-big-dns.patch /tmp
# mv /usr/src/redhat/sources/qmail-1.03-bind-interface.patch /tmp
#cd /tmp
#tar –zxvf qmail-1.03.tar.gz
#cd qmail-1.03
#patch –p1<../ qmail-1.03-big-dns.patch
#patch –p1 <../ qmail-1.03-bind-interface.patch
#make && make setup check
#./config
或者运行
# cd /var/qmail/control
# echo mail.sege.com.cn> me
# echo mail.sege.com.cn> defaultdomain
# echo mail.sege.com.cn> rcpthosts
# echo mail.sege.com.cn> locals
# echo mail.sege.com.cn> plusdomain
# echo localhost >> locals
# echo localhost >> rcpthosts
# ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
# cd /var/qmail/boot
# mv home ../rc
# /var/qmail/rc &
#echo /var/qmail/rc&>>/etc/rc.d/rc.local
# ps auxww | grep qmail and find the ``qmail-lspawn process together with a few others. test the
# uname -a | mail gujian@sege.com.cn
安装.forward兼容的转发服务:
#tar –zxvf dot-forward-0.71.tar.gz
#make setup check
#cp /var/qmail/boot/home+df /var/qmail/rc
注意必须手工将rc文件的格式修改为如下:
#!/bin/sh
exec env - path="/var/qmail/bin:$path"
qmail-start |dot-forward .forward ./maildir splogger qmail
这样在/home/vpopmail/domains/domainname/username/maildir/.forward 文件就可以生效了。
安装ucspi-tcp
# tar xzvf ucspi-tcp-0.88.tar.gz
# cd ucspi-tcp-0.88
# make && make setup check
this will compile and install ucspi-tcp files in your /usr/local directory.
建立/etc/tcp.smtp 文件,内容为
127.0.0.:allow,relayclient=
192.168.1.:allow,relayclient=
:allow
relay 规则建立。
# tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
让规则生效
建立smtp服务启动脚本/usr/sbin/runsmtp,内容如下
#!/bin/sh
/usr/local/bin/tcpserver -x/etc/tcp.smtp.cdb -u5002 -g1000
0 smtp /var/qmail/bin/qmail-smtpd 2>&1
| /var/qmail/bin/splogger &
#chmod +x /usr/sbin/runsmtp
#echo /usr/sbin/runsmtp >>/etc/rc.d/rc.local
启动smtp服务:
#/usr/sbin/runsmtp
checking to see if it worked
check to see if you have done everything correctly by doing this:
# telnet mail.dexterslab.net smtp you should see:
trying 192.168.1.1...
connected to mail.dexterslab.net.
escape character is ].
220 mail.dexterslab.net esmtp try saying hello. type in
helo johnnybravo.com it should say:
250 mail.dexterslab.net type ``quit to close connection. we will do serious testing later.
设置系统别名
# cd /var/qmail/alias
# echo &gujian > .qmail-root
# echo &gujian > .qmail-toor
# echo &gujian > .qmail-postmaster
# echo &gujian > .qmail-admin
# echo &gujian@sege.com.cn > .qmail-gujian
设置pop3:
保证系统没有开pop3服务
root@mail:# killall -hup inetd
运行下条命令启动pop3服务:
:# /usr/local/bin/tcpserver -u0 -g0 0 110 /var/qmail/bin/qmail-popup mail.sege.com.cn /usr/local/bin/checkvpw /var/qmail/bin/qmail-pop3d maildir 2>&1 | /var/qmail/bin/splogger &
将这条命令写入/usr/sbin/runpop文件中。
#chmod +xꗬá‹Љ 勸¿ က Ѐ 䱘
l ø ø ø ø ø ø ø ì ⨄ ⨄ ⨄ ⨄ ⨠ Œ ì 侭 IJ ⪸ ⫎ ⫎ ⫎ ⫎ ⫎ ⫎ ⫎ ䷨ ䷪ ䷪ ䷪ ䷪ ䷪ ䷪ $ 僟 Ƞ 勿 r 与 ř ø ⫎ ⫎ ⫎ ⫎ ⫎ 与 .smtp /home/vpopmail/etc
# tar -zxvf vpopmail-4.10.21.tar.gz
#cd vpopmail-4.10.21
#vi vmysql.h
将文件中的mysql设置为你的mysql配置
#crontab –e
添加以下内容:
40 * * * * /home/vpopmail/bin/clearopensmtp 2>&1 >/dev/null
#./configure --enable-roaming-users=y --enable-hardquota=100000000 --enable-default-domain=sege.com.cn --enable-mysql=y --enable-sqlincdir=/usr/local/include/mysql --enable-sqllibdir=/usr/local/lib/mysql --enable-ucspi-dir=../ucspi-tcp-0.88 --enable-passwd=n --enable-clear-passwd=y
#make
#make install
添加虚拟域:
#/home/vpopmail/bin/vadddomain sege.com.cn
#/home/vpopmail/bin/vadddomain china.com
添加虚拟用户:
/home/vpopmail/bin/vadduser gujian@sege.com.cn
设置支持pop3:
将/usr/sbin/runpop脚本内容改为如下内容:
/usr/local/bin/tcpserver -u vpopmail -g vchkpw 0 110 /var/qmail/bin/qmail-popu
p sege.com.cn /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d maildir 2>&1
| /var/qmail/bin/splogger &
#killall –9 tcpserver
#/usr/sbin/runsmtp
#/usr/sbin/runpop
可以通过以下命令测试pop用户了:
#telnet mail.china.com 110
#telnet mail.sege.com.cn 110
安装imap 服务器:
#tar –zxvf courier-imap-1.3.8.1.tar.gz
#cd courier-imap-1.3.8.1
# ./configure --disable-root-check
#make
#make install
#cd /usr/lib/courier-imap/etc
# cp imapd.dist imapd
# cp imapd-ssl.dist imapd-ssl
编辑imapd 文件:
maxperip: 40 (改4为40,让同一个ip地址最多可以有40个连接,为webmail的用户做准备的。)
authmodules:删除所有的模块,只留下authvchkpw
启动courier imap服务
# /usr/lib/courier-imap/libexec/imapd.rc start
将/usr/lib/courier-imap/libexec/imapd.rc start添加到/etc/rc.d/rc.local文件尾
配置apache+php+mysqladmin:
# gunzip -c apache_1.3.9.tar.gz | tar xf -
# cd apache_1.3.9
# ./configure
# cd ..
# gunzip -c php-4.0.x.tar.gz | tar xf -
# cd php-4.0.5
# ./configure --with-mysql --with-apache=../apache_1.3.9 --enable-track-vars --enable-gettext –disable-debug
# make
# make install
#cp php.ini-dist /usr/local/lib/php.ini
#cd ../apache_1.3.19
#./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a
#make
#make install
修改/www/conf/httpd.conf文件,启动apache
#/www/bin/apachectl start
vqregister-2.5.tar.gz (web方式的在线用户申请)
#tar –zxvf vqregister-2.5.tar.gz
#cd vqregister-2.5
# vi vqregister.conf 改为合适的配置。
以下是我的文件内容:
# vqregister configuration file
#
#
# adminemail
#
# syntax: adminemail
#
# sets the administrative contact
# for the vqregister program. any errors
# that are generated should contain this
# email address. see the template file,
# and the template files.
#
adminemail vol@inter7.com
# registeruser
#
# syntax: registeruser
#
# sets the username on the domain the user
# is signing up for, that vqregister sends
# out when verify is on. the domain is
# the user is signing up for is appended.
#
#registeruser vqregister
# subject
#
# syntax: subject
#
# sets the subject of the message
# that vqregister will put on the
# outgoing message when verify is on
#
#subject your new email account created by vqregister
# verify
#
# syntax: verify
# default: off
#
# sets whether or not you want
# vqregister to verify email addresses
# by sending a randomly set password
# to the users current email address.
# checking is done to see if the email
# address exists on the remote server.
#
#verify on
# allowpassword
#
# syntax: allowpassword
# default: off
#
# sets whether or not users can provide
# a password at registration time, rather
# than having one generated for them. when
# this option is enabled, users do not need
# to provide a current email address, but
# if they do, an email will be sent if
# verify is on. a new feature with allowpassword
# is that a user must also fill in a vpass
# field to verify the password they have typed.
#
allowpassword on
# allowdomain
#
# syntax: allowdomain
#
# sets domain.tld as registerable by
# users. any domains not listed here,
# cannot be signed up for.
#
allowdomain sege.com.cn
allowdomain china.com
# redirect
#
# syntax: redirect
#
# if you wish to redirect your users
# to a signup success page, you may
# do this with the redirect identifier.
# otherwise, the html/success.html template
# file will be outputted.
#
# note: the redirected url cannot support
# templates.
#
redirect http://gujian.sege.com.cn
# password
#
# syntax: password
#
# makes all passwords given to users be
# set to . elimates generation
# of random passwords. for use with redirect.
#
# passwordlen
#
# syntax: passwordlen
# default: 8
#
# sets the length of randomly generated
# passwords.
#
passwordlen 8
# badhosts
#
# syntax: badhosts
#
# defines a filename which, contains a list of email
# addresses one cannot signup from.
#
# example file:
# hotmail.com
# .cjb.net
# yahoo.com
# lycos.com
#
# if not defined, this feature is not turned on.
#
#badhosts badhosts
# db_host
#
# syntax: db_host
#
# set where to connect for the
# database.
#
#db_host localhost
# db_name
#
# syntax: db_name
#
# defines the database name to use
# when storing demographic, or other
# information.
#
#db_name user_store
# db_user
#
# syntax: db_user
#
# sets the username to use when
# connecting to the database
#
#db_user root
# db_password
#
# syntax: db_password
#
# defines the password for the
# database.
#
# note: databases are created if they do not exist (if able)
#
#db_password inter7
# db_fields
#
# syntax: db_fields [,[,]]
#
#db_fields user_info user,dom,pass,cemail,fname
# advertise
#
# syntax: advertise
# default: on
#
# were silly. turn this off to turn off the advertisement
# at the end of the outgoing email when verify is on.
#
#advertise on
修改html目录下的文件,使他们合适你的站点。
修改makefile文件,
将libs = -l$(vdir)/lib -lvpopmail -lcrypt -l/usr/local/mysql/lib/mysql -lmysqlclie
nt
改为:libs = -l$(vdir)/lib -lvpopmail -lcrypt -l/usr/local/lib/mysql -lmysqlclie
nt
#make
#make install
#cp –r /usr/local/apache/cgi-bin/vqregister /www/cgi-bin/
http://gujian.sege.com.cn/cgi-bin/vqregister/vqregister.cgi
安装webmail:
#cd /www/html
#tar –zxvf webmail.tar.gz
修改/www/webmail/config.php文件以适合你的站点就可以了。
总结:
由于本人才疏学浅错误之处难免,请大家指教。
(作者:古剑)
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!


