Qmail 1.03+Courier+vpopmail+mysql+qmailadmin+webmail安裝指南
對這個演示的補充說明-- Qmail 1.03+Courier+vpopmail+mysql安裝指南
請到 去看這個文檔的演示,用戶名: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
安裝.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 > .qmail-gujian
設置POP3:
保證系統沒有開pop3服務
:# 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
設置支持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
# 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 aclearcase/" target="_blank" >ccount 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 user@#s 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
# 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
#
# We@#re 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/
安裝WEBMAIL:
#cd /www/html
#tar –zxvf webmail.tar.gz
修改/www/webmail/config.php文件以適合你的站點就可以了。
總結:
由于本人才疏學淺錯誤之處難免,請大家指教。
(作者:古劍)