LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2689|回复: 0

FreeBSD 4.7 + Qmail + MySQL + Vpopmail + Igenus

[复制链接]
发表于 2003-5-31 10:32:57 | 显示全部楼层 |阅读模式
下面的文章是转帖redstone在igenus发表的。
希望大家一起学习freebsd.
qmil+mysql+vpopmail+igenus我在redhat 8下实现了,freebsd下我还没有实现。

REDSTONE
2003/04/02
FreeBSD下QMAIL的应用

FreeBSD 4.7 + Qmail + MySQL + Vpopmail + Igenus

需要的软件
* ucspi-tcp-0.88.tar.gz
http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
* checkpassword-0.90.tar.gz
http://cr.yp.to/checkpwd/checkpassword-0.90.tar.gz
* cmd5checkpw-0.22.tar.gz
http://members.elysium.pl/brush/ ... checkpw-0.22.tar.gz
* qmail-1.03.tar.gz(补丁为qmail-1.03patch及qmail-smtpd-auth-0.31.tar.gz)
http://cr.yp.to/software/qmail-1.03.tar.gz
http://www.ckdhr.com/ckd/qmail-103.patch
http://ftp.leo.org/download/pub/ ... oux/qmail-103.patch
http://members.elysium.pl/brush/ ... pd-auth-0.31.tar.gz
http://www.shupp.org/patches/qmail-maildir++.patch
http://shupp.org/patches/maildirquota-patch-2.1.gz
* mysql-max-3.23.55-unknown-freebsd4.7-i386.tar.gz
http://mysql.secsup.org/Download ... ebsd4.7-i386.tar.gz
* vpopmail-5.3.16.tar.gz
http://www.inter7.com/devel/vpopmail-5.3.16.tar.gz
* apache_1.3.27.tar.gz或httpd-2.0.43.tar.gz
http://www.apache.org/dist/httpd/apache_1.3.27.tar.gz
http://www.apache.org/dist/httpd/httpd-2.0.44.tar.gz
* php-4.3.0RC4.tar.gz
http://www.php.net/do_download.p ... df=php-4.3.0.tar.gz
http://www.php.net/do_download.p ... df=php-4.3.0.tar.gz
* sqwebmail-3.4.1.tar.gz
http://umn.dl.sourceforge.net/so ... ebmail-3.3.7.tar.gz
http://www.go.dlr.de/fresh/unix/ ... ebmail-3.4.1.tar.gz
* igenus_2_20030121_snap.tgz
http://www.igenus.org
*
相关软件
* courier-imap-1.5.3.tar.gz
http://umn.dl.sourceforge.net/so ... r-imap-1.5.3.tar.gz
* daemontools-0.76.tar.gz
http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
* autorespond.tar.gz
http://www.netmeridian.com/e-huss/autorespond.tar.gz
* ezmlm-0.53.tar.gz
http://cr.yp.to/software/ezmlm-0.53.tar.gz
* vqsignup-0.5.tar.gz

* vqregister-2.5.tar.gz

一、TCPSERVER的安装
1、安装tcpserver
# tar zxvf ucspi-tcp-0.88.tar.gz
# cd ucspi-tcp-0.88
# make setup check

2、生成tcp.smtp.cdb数据库
# cd /etc
# vi tcp.smtp
127.0.0.1:allow,RELAYCLIENT=""
# tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp

二、CHECKPASSWD及CMD5CHECKPW的安装
CHECKPASSWD
# tar zxvf checkpassword-0.90.tar.gz
# cd checkpassword-0.90
# make setup check

CMD5CHECKPW
# mkdir /usr/man
# makdir /usr/man/man8
# tar zxvf cmd5checkpw-0.22.tar.gz
# cd cmd5checkpw-0.22
# make
# make install

三、QMAIL的安装(包括tcpserver的安装,本机域名为test.mydomain.com)
1、建目录:
# mkdir /var/qmail
# mkdir /var/qmail/alias
# tar zxvf qmail-1.03.tar.gz

2、建组及用户:
# pw groupadd nofiles
# pw groupadd qmail
# pw useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent
# pw useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
# pw useradd qmaill -g nofiles -d /var/qmail -s /nonexistent
# pw useradd qmailp -g nofiles -d /var/qmail -s /nonexistent
# pw useradd qmailq -g qmail -d /var/qmail -s /nonexistent
# pw useradd qmailr -g qmail -d /var/qmail -s /nonexistent
# pw useradd qmails -g qmail -d /var/qmail -s /nonexistent
(添加一个系统用户admin,组为wheel,后面作为邮件管理用户)

4、使用补丁
补丁一(dns):
# patch -d ./qmail-1.03 < qmail-103.patch

补丁二(smtp):
# tar zxvf qmail-smtpd-auth-0.31.tar.gz
# cd qmail-smtpd-auth-0.31
# cp base* README.auth ../qmail-1.03
# patch -d ../qmail-1.03 < auth.patch
另外,如果想要对收、发的邮件进行备份的话,就需要对ertra.h文件进行修改
# cd ../qmail-1.03
# vi extra.h
# DEFINE QUEUE_EXTRA "Tlog\0"
# DEFINE QUEUE_EXTRALEN 5

# cd ..

补丁三(maildir_quota):如果只使用qmail邮箱并使用Maildir格式,使用vpopmail此补丁可以不用
# tar zxvf maildirquota-patch-2.1.gz
# patch -d ../qmail-1.03 < maildirquota-patch-2.1

5、进行编译:
# cd qmail-1.03
# make setup check

6、定制控制文件:
# ./config-fast test.mydomain.com

7、定义运行脚本及投送方式:cp /var/qmail/boot/home /var/qmail/rc
对rc文件进行修改,以决定投送方式:
# vi /var/qmail/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/binPATH" \
qmail-start ./Maildir/ splogger qmail

8、添加别名用户:
# touch /var/qmail/alias/.qmail-root
# touch /var/qmail/alias/.qmail-postmaster
# touch /var/qmail/alias/.qmail-mailer-daemon

# echo postmaster > /var/qmail/control/bouncefrom
(注意/var/qmail/control下的文件locals中必须有你的缺省域名,否则你的投递失败的邮件将会不知所踪)

9、停用sendmail:
# chmod 0 /usr/sbin/sendmail
# mv /usr/sbin/sendmail /usr/sbin/sendmail.bak
# cp /var/qmail/bin/sendmail /usr/sbin/sendmail
# vi /etc/rc.conf
(将sendmail_enable="YES"改为sendmail_enable="NO")

10、编写qmail启动脚本:
# vi /etc/rc.local
#!bin=bash
csh -cf '/var/qmail/rc &'

/usr/local/bin/tcpserver -c 100 -v -l test.domain.com -H -U -R 0 pop3 \
/var/qmail/bin/qmail-popup test.mydomain.com \
/bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir &

/usr/local/bin/tcpserver -H -R -l test.mydomain.com -t 1 -c 100 -v -p \
-x /etc/tcp.smtp.cdb -u 1002(用户qmaild的id号) -g 1001(组nofiles的id号) 0 smtp \
/var/qmail/bin/qmail-smtpd test.mydomain.com /bin/checkpassword /usr/bin/true \
/bin/cmd5checkpw /usr/bin/true &

11、
# chmod +x /etc/rc.local
reboot后用 telnet test.mydomain.com 25 和 telnet test.mydomain.com 110 进行测试

二、MySQL的安装
1、建组和用户:
# pw groupadd mysql
# pw useradd mysql -g mysql

2、进行编译:
# tar zxvf mysql-max-3.23.54a-i386.tar.gz
# cd mysql-max-3.23.54a-i386
# ./configure --prefix=/usr/local/mysql
# make
# make install
(我使用的是已经编译过的Mysql,安装方法为:
# tar zxvf mysql-max-3.23.54a-unknown-freebsd4.7-i386.tar.gz
# ln -s /usr/local/mysql /usr/local/download/mysql-max-3.23.54a-unknown-freebsd4.7-i386
)

3、运行脚本、添加目录:
# /usr/local/mysql/scripts/mysql_install_db
(# mkdir /usr/local/mysql/var)

4、更改文件和目录权限:
# chown -R root:mysql /usr/local/mysql
# chmod -R 640 /usr/local/mysql
# chmod -R u+X,g+X /usr/local/mysql
# chmod -R ug+x /usr/local/mysql/bin
# chmod -R g+w /usr/local/mysql/data
(# chmod -R g+w /usr/local/mysql/var)

5、
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

6、添加启动脚本:
# vi /etc/rc.local
cd /usr/local/mysql
./bin/safe_mysqld &

附:
1、更改root的密码:
#/usr/local/mysql/bin/mysqladmin -u root password 'password'
#/usr/local/mysql/bin/mysqladmin -u root -h test.mydomain.com password 'password'

2、添加vpopmail数据库,添加与root用户相同权限的用户vpopmail,在安装vpopmail时要用到
# cd /usr/local/mysql/bin
# ./mysql -u root -p
# Mysql>use mysql;
# Mysql>grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@localhost identified by '12345678';


三、vpopmail的安装
1、建立目录:
(之前要建个系统用户)
# mkdir /home/vpopmail
# mkdir /home/vpopmail/etc

2、建组及用户:
# pw groupadd vchkpw
# pw useradd vpopmail -g vchkpw

3、修改vmysql.h文件
# tar zxvf vpopmail-5.3.12.tar.gz
# cd vpopmail-5.3.12
# vi vmysql.h
#define MYSQL_UPDATE_SERVER "localhost" (mysql服务器名)
#define MYSQL_UPDATE_USER "vpopmail" (用户名)
#define MYSQL_UPDATE_PASSWD "12345678" (改成你设置的密码)

#define MYSQL_READ_SERVER "localhost" (mysql服务器名)
#define MYSQL_READ_USER "vpopmail" (用户名)
#define MYSQL_READ_PASSWD "12345678" (改成你设置的密码)

4、创建tcp.smtp文件(或者使用/etc/tcp.smtp)
# vi /home/vpopmail/etc/tcp.smtp
127.0.0.1:allow,RELAYCLIENT=""

5、进行编译:
# ./configure \\下面是我使用的参数
--prefix=/home/vpopmail \\指定安装路径
--enable-mysql=y \\是否应用Mysql数据库
--enable-incdir=/usr/local/mysql/include \\Mysql数据库include文件所在目录
--enable-libdir=/usr/local/mysql/lib \\Mysql数据库lib文件所在目录
--enable-default-domain=test.mydomain.com \\定义虚拟域名
--enable-passwd=n \\是否使用系统密码验证方式
--enable-defaultquota=52428800s \\定义缺省邮箱大小,10485760为10MB,20971520为20MB,52428800s为50MB
--enable-tcprules-prog=/usr/local/bin/tcprules \\指定tcprules目录
--enable-tcpserver-file=/home/vpopmail/etc/tcp.smtp \\指定tcprules应用规则文件
--enable-vpopuser=vpopmail \\vpopmail的用户
--enable-vpopgroup=vchkpw \\vpopmail的组
--enable-ip-alias-domains=n \\在虚拟域中允许通过反向IP地址查找虚拟域名
(--enable-roaming-users=y \\是否支持外地用户的SMTP的RELAY)
(--enable-sqwebmail-pass=y \\sqwebmail的密码支持)

# make
# make install-strip

附configure的主要参数:
--enable-qmaildir=dir directory where qmail control and user directories are installed. default is /var/qmail"
--enable-qmail-newu=path Full path to qmail-newu program"
--enable-qmail-inject=path Full path to qmail-inject program"
--enable-qmail-newmrh=path Full path to qmail-newmrh program"
--enable-vpopuser=vpopmail user vchkpw was installed as."
--enable-vpopgroup=vchkpw group vchkpw was installed as."
--enable-roaming-users=n|y Enable or disable open relay after pop authentication. Default is no"
--enable-tcprules-prog=/usr/local/bin/tcprules where is your tcprules program."
--enable-tcpserver-file=/home/vpopmail/etc/tcp.smtp File where tcpserver -x relay information is stored."
--enable-relay-clear-minutes=180 expire time for roaming users after pop authentication."
--enable-learn-passwords=y|n (n, default) if password is blank, learn password when they pop auth."
--enable-md5-passwords=y|n (y, default ) to store encrypted passwords as md5."
--enable-auth-logging=y|n (n, default) logging authentication attempts, only valid for mysql and oracle"
--enable-mysql-logging=y|n (n, default) logging detailed authentication attempts, only valid for mysql"
--enable-clear-passwd=n|y (y, default) storing clear text passwords"
--enable-logging=e|y|n|p|v (e) only log errors, include passwords (p), (v) verbose errors with passwords"
--enable-sqwebmail-pass=y|n sqwebmail passwords (n default) For sqwebmail-3.0 and above use default no"
--enable-log-name=vpopmail set syslog name."
--enable-domains-dir=domains set domains directory name for ~vpopmail/[domains]/user/."
--enable-default-domain=name Default domain name, default is null."
--enable-incdir=path-to-auth-include Directory where auth include files are."
--enable-libdir=path-to-auth-libs Directory where auth libs are."
--enable-libs=mysqlclient libraries for sql linking."
--enable-mysql=n|y use mysql, default is no"
--enable-mysql-replication=n|y (n, default) enable mysql replication"
--enable-valias=n|y (n, default) enable mysql alias processing"
--enable-file-locking=n|y (y, default) enable file locking"
--enable-file-sync=y|n (n default) enable file sync"
--enable-many-domains=n|y (y, default) no optimizes for sites with one domain and many users"
--enable-ldap=n|y use ldap, default is no"
--enable-oracle=n|y use oracle, default is no"
--enable-sybase=n|y use sybase, default is no"
--enable-qmail-ext=y|n enable qmail email address extensions (default no). "
--enable-ip-alias-domains=y|n enable virutal domain lookup via reverse ip address lookup for virtual domains. "
--enable-passwd=y|n Enable or disable /etc/passwd (or shadow) authentication. Default is no"
--enable-defaultquota=# or n where # is the quota as defined in README.quotas. NOT y, do not use Y, y is BAD"

6、创建虚拟域
# cd /home/vpopmail/bin
# ./vadddomain (test.mydomain.com) (password) (在mysql数据库vpopmail中自动生成vpopmail表单)
(如果使用与机器名相同的虚拟域名,应先生成一个其它的虚拟域名,不然会有问题,无法自动生成vpopmail数据库)
# ./vadduser (user) (password) (会自动往表vpopmail中添加用户数据)

如果不成功的话,则必须先删除创建的域,./vdeldomain (test.mydomain.com)

7、修改启动脚本
# vi /etc/rc.local

#!bin=bash
csh -cf '/var/qmail/rc &'

/usr/local/bin/tcpserver -c 100 -v -l test.domain.com -H -U -R 0 pop3 \
/var/qmail/bin/qmail-popup test.mydomain.com \
/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir &

# 1002为用户qmaild的id号,1001为组nofiles的id号
/usr/local/bin/tcpserver -H -R -l test.mydomain.com -t 1 -c 100 -v -p \
-x /etc/tcp.smtp.cdb -u 1002 -g 1001 0 smtp \
/var/qmail/bin/qmail-smtpd test.mydomain.com /home/vpopmail/bin/vchkpw /usr/bin/true \
/bin/cmd5checkpw /usr/bin/true &

8、如果虚拟域名与机器名不同,要添加机器名到qmail控制文件中
# echo "test.mydomain.com" >> rcpthost
# echo "test.mydomain.com" >> locals

四、APACHE的安装
1、定义路径,如果要安装PHP4要加上--enable-module=so参数
# ./configure
--prefix=/usr/local/apache \
--enable-module=so \
--server-uid=vpopmail \
--server-gid=vchkpw \

# make
# make install

2、编辑/usr/local/apache/conf/http.conf
# vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
DirectoryIndex index.html login.php

3、在/etc/rc.local
/usr/local/apache/bin/apachectl start

五、PHP4的安装
1、编译安装
# ./configure
--prefix=/usr/local/php4
--with-mysql=/usr/local/mysql \
--with-apxs=/usr/local/apache/bin/apxs

# make
# make install

2、拷贝文件并编辑:
# cp php.ini-dist /usr/local/php4/lib/php.ini
# vi /usr/local/php4/lib/php.ini
max_execution_time=60
memory_limit=20M
post_max_filesize=10M
file_uploads=on
upload_max_filesize=10M
register_globals=On
session.bug_compat_42=0
session.bug_compat_warn=0
(php的状况可以用/usr/local/php4/bin/php -i检查)

3、编辑httpd.conf,检查下面的语句存在并且没有被注释掉
# vi /usr/local/apache/conf/httpd.conf
LoadModule php4_module libexec/libphp4.so

六、Sqwebmail的安装


七、igenus的安装
1、CVS下载最新版本或下载软件包
CVS下载安装
cd /usr/local/apache/htdocs

cvs -d :pserver:anoncvs@cvs.igenus.org:/home/cvsroot co igenus

下载软件包安装
tar zxvf igenus_2_20020826_snap.tgz
cp -R snap /usr/local/apache/htdocs/igenus

2、建temp文件夹
cd /usr/local/apache/htdocs/igenus
mkdir temp
chmod -R 0755 temp
chown -R vpopmail:vchkpw temp

3、修改config_inc.php文件
# cd /usr/local/apache/htdocs/igenus/config
# vi config_inc.php
$CFG_BASEPATH = "/usr/local/apache/htdocs/igenus";

$CFG_MYSQL_HOST = 'localhost';
$CFG_MYSQL_USER = 'vpopmail';
$CFG_MYSQL_PASS = '12345678'; \\改成你的密码
$CFG_MYSQL_DB = 'vpopmail';

$CFG_TEMP = $CFG_BASEPATh."/temp";


4、重新编制Mysql数据库表格
cd /home/vpopmail/bin
../vdeldomain test.mydomain.com

cd /usr/local/mysql/bin
../mysql -u root -p

use vpopmail;

drop table vpopmail;

create table vpopmail
( pw_id int(5) unsigned NOT NULL auto_increment,
pw_name varchar(32) NOT NULL default '',
pw_domain varchar(64) NOT NULL default '',
pw_passwd varchar(40) NOT NULL default '',
pw_uid int(11) default NULL,
pw_gid int(11) default NULL,
pw_gecos varchar(64) default NULL,
pw_dir varchar(160) default NULL,
pw_shell varchar(20) default NULL,
pw_clear_passwd varchar(16) default NULL,
PRIMARY KEY (pw_id),
KEY pw_name (pw_name,pw_domain)
) TYPE=MyISAM;

(或者
use vpopmail;
alter table vpopmail drop primary key;
alter table vpopmail add column pw_id int(5) NOT NULL primary key auto_increment;
)

create table address
(
id int(11) unsigned NOT NULL auto_increment,
pw_id int(5) unsigned NOT NULL default '0',
name varchar(64) NOT NULL default '',
email varchar(128) NOT NULL default '',
UNIQUE KEY id (id),
KEY pw_id (pw_id)
) TYPE=MyISAM;

quit;

cd /home/vpopmail/bin
../vadddomain test.mydomain.com
../vadduser XXX (再添加所有用户)


5、编辑index.html文件
vi /usr/local/apache/htdocs/index.html

<html>
<head>
<title>index.html</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="0;url=http://192.168.0.108(你的机器IP)/igenus/login.php">
</head>

<body bgcolor="#FFFFFF" text="#000000">

</body>
</html>

6、在浏览器地址栏输入
http://你邮件服务器的地址/http://你邮件服务器的地址/igenus/
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表