安装软件系统
1)、安装MySQL4.0.x
为了与系统的软件系统区分开,这里将所有我们手动编译的服务器(DAEMON)软件安装在/usr/server中。
$ tar -zxvf mysql-4.0.21.tar.gz
$ cd mysql-4.0.21
$ ./configure --prefix=/usr/server/mysql --localstatedir=/usr/server/mysql/db --with-unix-socket-path=/tmp/mysql.sock --with-mysqld-user=mysql --with-charset=gb2312 --with-extra-charsets=all
$ make
$ su root
# make install
接下来安装mysql数据库
# pw groupadd mysql
# pw useradd mysql -g mysql
# scripts/mysql_install_db
# chown -R mysql:mysql /usr/server/mysql/db
最后需要设置mysql的root口令
# /usr/server/mysql/bin/mysqld_safe &
# /usr/server/mysql/bin/mysqladmin -uroot password 'your_password_goes_here'
口令设置完成后,暂时关闭mysql服务:
# kill %1
2)、安装Cyrus-sasl2
因为要查询MySQL数据库,所以我们需要在编译cyrus-sasl2时加上对MySQL的支持,同时我们打开了对plain和login两种验证方式的支持:
$ tar -zxvf cyrus-sasl-2.1.19.tar.gz
$ cd cyrus-sasl-1.2.19
$ ./configure --disable-anon -enable-plain --enable-login --enable-sql --with-mysql=/usr/server/mysql
$ make
$ su root
# make install
按照sasl的安装说明,需要建立一个symblink:
# ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
3)、安装Postfix2.1.x
首先,按照postfix的安装说明,建立postfix、postdrop组和postfix用户:
# pw groupadd postfix
# pw groupadd postdrop
# pw useradd postfix -g postfix -G postdrop
用户和组建立好后,我们就可以开始编译Postfix了:
$ tar -zxvf postfix-2.1.4.tar.gz
$ cd postfix-2.1.4
$ make tidy
$ make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/server/mysql/include/mysql -DUSE_SASL_AUTH -I/usr/local/include/sasl' 'AUXLIBS=-L/usr/server/mysql/lib/mysql -lmysqlclient -lm -lz -L/usr/local/lib -lsasl2'
$ make
$ su root
# make install
在执行make install的时候可能会得到如下的提示(如果没有就不用理会了:p):
/usr/libexec/ld-elf.so.1: Shared object "libmysqlclient.so.12" not found
这是因为我们的mysql不是安装在默认目录中的,所以需要告诉postfix应该到哪里去找libmysqlclient.so.12,使用ldconfig就可以达到这个目的:
# ldconfig -m /usr/server/mysql/lib/mysql
然后再执行make install这里会出现很多问题,但postfix已经为我们设置好了默认的答案,直接使用这些答案就可以使postfix正常工作了,所以我们只要直接按回车就可以了。
到这里,支持mysql和sasl认证的postfix就已经安装成功了。
4)、安装Courier-imap
$ tar -jxvf courier-imap-3.0.7.tar.bz2
$ cd courier-imap-3.0.7
$ ./configure --prefix=/usr/server/courier-imap --with-authmysql --enable-unicode
在执行configure的时候有可能会出现如下的错误提示:
configure: error: --with-authmysql specified but no mysqlclient.so
configure: error: /usr/local/bin/bash './configure' failed for authlib
这是因为courier-imap会使用mysql_config来取得一些编译参数(include、libs、cflags、socket等),但我们是将mysql安装在非/usr/local中,所以默认的PATH就不起作用,需要我们来使courier-imap能够搜索到 mysql_config:
$ export PATH="$PATH:/usr/server/mysql/bin"
上面用的SHELL是sh,如果是csh则执行
$ setenv PATH "${PATH}:/usr/server/mysql/bin"
然后再次执行configure脚本:
$ ./configure --prefix=/server/courier-imap --with-authmysql --enable-unicode
$ make
$ su root
# make install
配置系统
1)、建立用户数据表结构
这里,我们直接使用postfixadmin-2.0.5的表结构,现在我们来解开postfixadmin:
$ tar -zxvf postfixadmin-2.0.5.tgz
$ cd postfixadmin-2.0.5
在postfixadmin-2.0.5.tgz中有一个DATABASE.TXT文件,其中描述了各个表的结构,它的内容如下:
#############################
# Postfix Admin Release 2.x #
#############################
#
# Copyright (c) 2002, 2003, 2004 High5!
# Created by: Mischa Peters
#
# This is the complete database structure for Postfix Admin.
# If you are installing from scratch you can use this file otherwise you
# need to use the TABLE_CHANGES.TXT or TABLE_BACKUP_MX.TXT that comes with Postfix Admin.
#
# There are 2 entries for a database user in the file.
# One you can use for Postfix and one for Postfix Admin.
#
# If you run this file twice (2x) you will get an error on the user creation in MySQL.
# To go around this you can either comment the lines below "USE MySQL" until "USE postfix".
# Or you can remove the users from the database and run it again.
#
# You can create the database from the shell with:
#
# mysql -u root [-p] < DATABASE.TXT
#
# Postfix / MySQL
#
USE mysql;
# Postfix user & password
INSERT INTO user (Host, User, Password) VALUES ('localhost','postfix',password('postfix'));
INSERT INTO db (Host, Db, User, Select_priv) VALUES ('localhost','postfix','postfix','Y');
# Postfix Admin user & password
INSERT INTO user (Host, User, Password) VALUES ('localhost','postfixadmin',password('postfixadmin'));
INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('localhost', 'postfix', 'postfixadmin', 'Y', 'Y', 'Y', 'Y');
FLUSH PRIVILEGES;
GRANT USAGE ON postfix.* TO postfix@localhost;
GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfix@localhost;
GRANT USAGE ON postfix.* TO postfixadmin@localhost;
GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfixadmin@localhost;
CREATE DATABASE postfix;
USE postfix;
#
# Table structure for table admin
#
CREATE TABLE admin (
username varchar(255) NOT NULL default '',
password varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (username),
KEY username (username)
) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Admins';
#
# Table structure for table alias
#
CREATE TABLE alias (
address varchar(255) NOT NULL default '',
goto text NOT NULL,
domain varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (address),
KEY address (address)
) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Aliases';
#
# Table structure for table domain
#
CREATE TABLE domain (
domain varchar(255) NOT NULL default '',
description varchar(255) NOT NULL default '',
aliases int(10) NOT NULL default '-1',
mailboxes int(10) NOT NULL default '-1',
maxquota int(10) NOT
(http://www.fanqiang.com)