安装qmail具体步骤:
需要的安装包,可从http://shupp.org/toaster/#download下载
mkdir /usr/local/src
cd /usr/local/src
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
wget http://shupp.org/software/netqmail-1.05.tar.gz
wget http://shupp.org/patches/qmail-toaster-0.8.3.patch.bz2
wget http://shupp.org/software/vpopmail-5.4.13.tar.gz
wget http://shupp.org/patches/vpopmail-5.4.13-cumulative-1.patch
wget http://shupp.org/software/autorespond-2.0.4.tar.gz
wget http://shupp.org/patches/autorespond-2.0.4-2.0.5.patch
wget http://shupp.org/software/qmailadmin-1.2.10.tar.gz
wget http://shupp.org/software/qmailadmin-help-1.0.8.tar.gz
wget http://shupp.org/software/courier-imap-4.1.0.tar.bz2
wget http://shupp.org/software/courier-authlib-0.58.tar.bz2
wget http://shupp.org/software/quota_usage-1.3.1-1.2.7.tar.gz
wget http://shupp.org/software/toaster-scripts-0.8.1.tar.gz
确认环境:rpm -qa |grep g++ gcc-g++ gdbm gdbm-devel openssl openssl-devel stunnel krb5-devel bzip2 bzip2-devel 如果缺什么,就用随机盘安装上(需要安装的开发包,否则编译失败)
二、正文(安装lamp,利用源代码包安装或rpm安装都可,做实验利用yum安装方式)
# 1、安装mysql
# 到 http://www.mysql.org/下载最新版的mysql,此安装时为5.0.19
# 按照mysql安装说明安装如下
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < src/mysql-standard-5.0.19-linux-i686.tar.gz | tar xvf -
shell> ln -s mysql-standard-5.0.19-linux-i686 mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
# 然后使mysql随系统一起启动
cp support-files/mysql.server /etc/init.d/mysql
chkconfig –add mysql
# 现在给mysql的root用户设定密码
./bin/mysqladmin -uroot -password 'mysql'(红色文字为密码,自己设定)
# 2、安装apache
# 下载:由http://www.apache.com/ 下载最新版
wget http://httpd.apache.org/download.cgi/httpd-2.2.3.tar.gz
groupadd www
useradd -g www www
tar –zxvf httpd-2.2.3.tar.gz
./configure --prefix=/usr/local/apache --enable-so --enable-cgi
make
make install
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
chmod +x /etc/rc.d/init.d/httpd
chkconfig --add httpd
service httpd start
# 打开iptables的80端口,http://你的ip,测试安装是否成功
# 3、安装php
# 下载:
wget http://cn.php.net/get/php-5.1.6.tar.gz
tar -zxvf php-5.1.6.tar.gz
cd php-5.1.6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql
make
make install
cp php.ini-dist ../../php/lib/php.ini
chown -R root.www /usr/local/php/lib/php
chmod -R g-w,o-rwx /usr/local/php/lib/php
cd /usr/local
chown -R root.root apache/
chmod 755 apache
chmod -R 600 apache/*
chmod -R u+x apache
cd apache/
chmod -R u+x bin
chgrp -R www cgi-bin
chmod -R u+x,g+x cgi-bin
chgrp -R www logs
chmod g+wX logs
chgrp -R www htdocs
chmod -R g+rX htdocs
# 设置允许上传下载的邮件的大小
vi /usr/local/php/lib/php.ini
max_execution_time=60
memory_limit=20M
post_max_size = 10M
file_uploads=on
upload_max_filesize=10M
register_globals=On
session.bug_compat_42=0
session.bug_compat_warn=0
sendmail_path = /var/qmail/bin/qmail-inject
# 4、安装 qmail
# 在安装qmail以前,需要尽量看懂Life with qmail(http://www.lifewithqmail.org/),这是安装qmail的说明文件
# 确认没有SMTP/POP/IMAP服务在运行:
/etc/init.d/sendmail stop
netstat -na | grep 25
netstat -na | grep 110
netstat -na | grep 143
service sendmail stop
# 删除已有的SMTP/POP/IMAP软件:
rpm -e --nodeps sendmail
# 下载
wget http://www.qmail.org/netqmail-1.05.tar.gz
wget ucspi-tcp, http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
wget daemontools, http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
mv netqmail-1.05.tar.gz ucspi-tcp-0.88.tar.gz /usr/local/src
mkdir -p /package
mv daemontools-0.76.tar.gz /package
chmod 1755 /package
cd /usr/local/src
gunzip netqmail-1.05.tar.gz
tar xpf netqmail-1.05.tar
cd netqmail-1.05
./collate.sh # 这一步绝对不能省略
cd ..
gunzip ucspi-tcp-0.88.tar.gz
tar xpf ucspi-tcp-0.88.tar
cd /package
gunzip daemontools-0.76.tar.gz
tar xpf daemontools-0.76.tar
# 建立qmail目录
mkdir /var/qmail
# 建立用户
groupadd nofiles
useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
useradd alias -g nofiles -d /var/qmail/alias -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
cd /usr/local/src/netqmail-1.05/netqmail-1.05
# 删除sendmail的链接
rm -rf /usr/sbin/sendmail
make
make setup check
#( 如果已申请域名解析,则执行
chmod u+x config.sh
./config.sh)应具体情况而定。
# 否则,用你自己的主机名代替下面的mail.domain.com (主机名+域名,具体可以参考qmail中文文档)
chmod u+x config-fast.sh
./config-fast.sh mail.domain.com
# 注意qmail的补丁将在vpopmail安装以后打
# 安装 ucspi-tcp
cd /usr/local/src/ucspi-tcp-0.88
patch < /usr/local/src/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
make
make setup check
# 安装daemontools
cd /package/admin/daemontools-0.76
cd src
patch < /usr/local/src/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
cd ..
package/install
#发往root/postmaster/mailer-daemon地址的邮件将会由定义的管理员邮箱接收。
#将如下的“[email protected]"替换成你的管理员邮箱。
cd /var/qmail/alias
echo "[email protected]" > .qmail-postmaster
echo "[email protected]" > .qmail-mailer-daemon
echo "[email protected]" > .qmail-root
chmod 644 /var/qmail/alias/.qmail*
echo ./Maildir/ >/var/qmail/control/defaultdelivery
#开启SPF设置
echo 3 > /var/qmail/control/spfbehavior
#添加qmail的帮助手册
echo MANPATH /var/qmail/man >> /etc/man.config
#建立监控和日志目录及文件
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
mkdir -p /var/qmail/supervise/qmail-pop3ds/log
cp toaster-scripts-0.8/send.run /var/qmail/supervise/qmail-send/run
cp toaster-scripts-0.8/send.log.run /var/qmail/supervise/qmail-send/log/run
cp toaster-scripts-0.8/smtpd.run /var/qmail/supervise/qmail-smtpd/run
cp toaster-scripts-0.8/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run
cp toaster-scripts-0.8/pop3d.run /var/qmail/supervise/qmail-pop3d/run
cp toaster-scripts-0.8/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run
cp toaster-scripts-0.8/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run
cp toaster-scripts-0.8/pop3ds.log.run /var/qmail/supervise/qmail-pop3ds/log/run
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
chmod 755 /var/qmail/supervise/qmail-pop3d/run
chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/log/run
mkdir -p /var/log/qmail/smtpd
mkdir -p /var/log/qmail/pop3d
mkdir -p /var/log/qmail/pop3ds
chown -R qmaill /var/log/qmail
#建立脚本
tar –zxv toaster-scripts-0.8.1.tar.gz
cd toaster-scripts-0.8.1
cp toaster-scripts-0.8/rc /var/qmail/rc
chmod 755 /var/qmail/rc
mkdir /var/log/qmail
cp toaster-scripts-0.8/qmailctl /var/qmail/bin/
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
#允许daemontools来启动qmail
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service
#检测qmail是否安装成功
sleep 5
qmailctl stat
# 5、安装vpopmail
# 下载:
wget http://umn.dl.sourceforge.net/sourceforge/vpopmail/vpopmail-5.4.17.tar.gz
groupadd -g 89 vchkpw
useradd -u 89 -g vchkpw vpopmail
cd /usr/local/src
tar –zxvf vpopmail-5.4.17.tar.gz
cd vpopmail-5.4.17
mkdir -p /home/vpopmail/etc
echo "你的虚拟域名" > /home/vpopmail/etc/defaultdomain (自己设定虚拟域名为domain.com)
# 设置mysql信息,
echo "localhost|0|vpopmailuser|vpoppasswd|vpopmail" > ~vpopmail/etc/vpopmail.mysql(即/home/vpopmail/etc/vpopmail.mysql)
chown vpopmail.vchkpw ~vpopmail/etc/vpopmail.mysql
chmod 640 ~vpopmail/etc/vpopmail.mysql
chown vpopmail.vchkpw ~vpopmail/etc
# 设置smtp规则,关闭open relays
echo '127.0.0.1:allow,RELAYCLIENT=""' > /home/vpopmail/etc/tcp.smtp
cd /home/vpopmail/etc
tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp
#在mysql里添加vpopmail的帐号
Mysql –uroot –pmysql
CREATE DATABASE vpopmail;
GRANT select,insert,update,delete,create,drop ON vpopmail.*
TO vpopmail@localhost IDENTIFIED BY '123456';(创建用户名及密码,须编辑/home/vpopmail/etc/vpopmail.mysql,需要前后保持一致)
FLUSH PRIVILEGES;
QUIT
./configure --disable-roaming-users --enable-logging=p --disable-passwd --enable-clear-passwd --disable-domain-quotas --enable-auth-module=mysql --enable-auth-logging --enable-sql-logging --disable-valias --disable-mysql-limits --enab
le-learn-passwords
make
make install-strip
echo 'export PATH=$PATH:/home/vpopmail/bin' >> /etc/profile
. /etc/profile
cp ../toaster-scripts-0.8.1/vpopmailctl /var/qmail/bin/vpopmailctl
chmod 755 /var/qmail/bin/vpopmailctl
ln -s /var/qmail/bin/vpopmailctl /usr/bin
# 这时候我们可以安装qmail的补丁了
cd /var/src/netqmail-1.05/netqmail-1.05
bunzip2 -c ../../tar/qmail-toaster-0.8.3.patch.bz2 | patch -p0
make clean
make
qmailctl stop
make setup check
chown -R vpopmail:vchkpw /var/qmail/spam
#创建SSL Key(具体参考qmail中文文档)
make cert
make tmprsadh
#注:这里可能要多等一会
chown -R vpopmail:qmail /var/qmail/control/clientcert.pem /var/qmail/control/servercert.pem
# 用"crontab -e"在crontab里增加下面这条,每天晚上更新temp keys
01 01 * * * /var/qmail/bin/update_tmprsadh > /dev/null 2>&1 (做实验,省去这步,依具体情况而定)
# 重启启动qmail
qmailctl start (比如路径为/var/qmail/bin/qmailctl start)
# 允许daemontools来启动vpopmail
ln -s /var/qmail/supervise/qmail-pop3d /var/qmail/supervise/qmail-pop3ds /service
# 检测vpopmail
sleep 5
vpopmailctl stat
# 测试
# 添加域:
/home/vpopmail/bin/vadddomain domain.com 123456(postmaster密码)
# 添加用户:
/home/vpopmail/bin/vadduser -q 6MB [email protected]
# 然后用outlook测试一下你新建的帐号,就ok了
三、webmail
# 安装webmail
# 安装courier-imap
# 下载:
wget http://superb-west.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.1.tar.bz2
wget http://superb-west.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.58.tar.bz2
# a、安装 Courier's Auth Library:
tar –jxvf courier-authlib-0.58.tar.bz2
cd courier-authlib-0.58
./configure --prefix=/usr/local --exec-prefix=/usr/local --with-authvchkpw --without-authldap --without-authmysql --disable-root-check --with-ssl --with-authchange pwdir=/usr/local/libexec/authlib --with-redhat
make
make install
make install-configure
cp courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod 755 /etc/init.d/courier-authlib
ln -s ../init.d/courier-authlib /etc/rc0.d/K30courier-authlib
ln -s ../init.d/courier-authlib /etc/rc1.d/K30courier-authlib
ln -s ../init.d/courier-authlib /etc/rc2.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc3.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc4.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc5.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc6.d/K30courier-authlib
vi /usr/local/etc/authlib/authdaemonrc
Change authmodulelist="..." to authmodulelist="authvchkpw" 并将认证进程改为2
# 然后启动它:
/etc/init.d/courier-authlib start
# b、安装Courier-IMAP
tar -xjf tar/courier-imap-4.1.1.tar.bz2
cd courier-imap-4.1.1
# 作为 vpopmail 用户安装
chown -R vpopmail:vchkpw ../courier-imap-4.1.1
su vpopmail
umask 0022
./configure –with-redhat
# NOTE: RedHat/Fedora users need to add "--with-redhat"
make
exit
make install-strip
make install-configure
cp courier-imap.sysvinit /etc/init.d/courier-imap
chmod 755 /etc/init.d/courier-imap
ln -s ../init.d/courier-imap /etc/rc0.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc1.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc2.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc3.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc4.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc5.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc6.d/K30courier-imap
vi /usr/lib/courier-imap/etc/imapd
# Change 'IMAPDSTART=NO' to 'IMAPDSTART=YES'
vi /usr/lib/courier-imap/etc/imapd-ssl
# Change 'IMAPDSSLSTART=NO' to 'IMAPDSSLSTART=YES'
vi /usr/lib/courier-imap/etc/imapd.cnf
# CN=domain.com
# [email protected]
vi /usr/lib/courier-imap/etc/pop3d.cnf
# CN=domain.com
# [email protected]
#启动 IMAP server
/etc/init.d/courier-imap start
1、 # 安装sqwebmail
# 下载
wget http://superb-west.dl.sourceforge.net/sourceforge/courier/sqwebmail-5.1.3.tar.bz2
tar –jxvf sqwebmail-5.1.3.tar.bz2
cd sqwebmail-5.1.3
./configure --enable-webpass=vpopmail --enable-softtimeout=3600 --enable-hardtimeoout=14400 --enable-webpass=yes --enable-autopure=10 --enable-maxpurge=300 --enable-mimecharset=gb2312 --with-maxargsize=5000000 --with-maxformargsize=5000000 --with-maxmsgsize=5000000 --without-ispell --with-authvchkpw --enable-unicode
make configure-check
umask 220
make
make check
make install-strip
make install-configure
#启动脚本在/usr/local/sqwebmail/libexec/sqwebmaild.rc,
# 要把它放到/etc/init.d,并且让他启动时运行
/usr/lib/sqwebmail/libexec/sqwebmaild.rc start
su -c "/usr/lib/sqwebmail/share/sqwebmail/cleancache.pl"
cp /usr/lib/sqwebmail/libexec/sqwebmaild.rc /etc/init.d/sqwebmaild
chmod 755 /etc/init.d/sqwebmaild
ln -s /etc/init.d/sqwebmaild /etc/rc.d/rc3.d/S89sqwebmaild
ln -s /etc/init.d/sqwebmaild /etc/rc.d/rc5.d/S89sqwebmaild
#用"crontab -e"在crontab里增加下面这条,定时清除cache
crontab –e
*/30 * * * *su -c "/usr/lib/sqwebmail/share/sqwebmail/cleancache.pl"(依据具体情况而定,实验省去)
#登录http://domain.com/cgi-bin/sqwebmail 验证是否安装成功。