因為要查詢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 --with-mysql-includes=/usr/server/mysql/include/mysql --with-mysql-libs=/usr/server/mysql/lib/mysql $ make # 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 # 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=/server/courier-imap --with-authmysql 在執行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" 然後再次執行configure腳本: $ ./configure --prefix=/server/courier-imap --with-authmysql $ make # 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 NULL default '-1', transport varchar(255) default NULL, backupmx tinyint(1) NOT NULL default '0', 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 (domain), KEY domain (domain) ) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Domains';
# # Table structure for table domain_admins # CREATE TABLE domain_admins ( username varchar(255) NOT NULL default '', domain varchar(255) NOT NULL default '', created datetime NOT NULL default '0000-00-00 00:00:00', active tinyint(1) NOT NULL default '1', KEY username (username) ) TYPE=MyISAM COMMENT='Postfix Admin - Domain Admins';
# # Table structure for table log # CREATE TABLE log ( timestamp datetime NOT NULL default '0000-00-00 00:00:00', username varchar(255) NOT NULL default '', domain varchar(255) NOT NULL default '', action varchar(255) NOT NULL default '', data varchar(255) NOT NULL default '', KEY timestamp (timestamp) ) TYPE=MyISAM COMMENT='Postfix Admin - Log';
# # Table structure for table mailbox # CREATE TABLE mailbox ( username varchar(255) NOT NULL default '', password varchar(255) NOT NULL default '', name varchar(255) NOT NULL default '', maildir varchar(255) NOT NULL default '', quota int(10) NOT NULL default '-1', 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 (username), KEY username (username) ) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Mailboxes';
# # Table structure for table vacation # CREATE TABLE vacation ( email varchar(255) NOT NULL default '', subject varchar(255) NOT NULL default '', body text NOT NULL, cache text NOT NULL, domain varchar(255) NOT NULL default '', created datetime NOT NULL default '0000-00-00 00:00:00', active tinyint(1) NOT NULL default '1', PRIMARY KEY (email), KEY email (email) ) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Vacation';
測試pop3 $ telnet localhost 110 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. +OK Hello there. USER test@cnfug.org +OK Password required. PASS test +OK logged in. 上面的提示表示我們的pop3登錄也成功了 :)。
五、安裝配置Postfixadmin-2.0.5和iGENUS_2.0.2
現在所有的後台服務已經正常工作了,現在我們就開始安裝管理界面和用戶界面。
1)、安裝postfixadmin-2.0.5 postfixadmin可以在http://high5.net/postfixadmin處得到,下載后是一個名為postfixadmin-2.0.5.tgz的文件 $ tar -zxvf postfixadmin-2.0.5.tgz $ mv postfixadmin-2.0.5 postfixadmin $ cd postfixadmin 為了讓postfixadmin正常工作,需要進行一些小的設置,將postfixadmin目錄中的config.inc.php.sample複製為config.inc.php,然後編輯其中的參數: $ cp config.inc.php.sample config.inc.php $ vi config.inc.php 本例中的配置如下: // Language config // Language files are located in './languages'. $CONF['default_language'] = 'cn';
// Database Config // 'database_type' is for future reference. $CONF['database_type'] = 'mysql'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfixadmin'; $CONF['database_password'] = 'postfixadmin'; $CONF['database_name'] = 'postfix';
$CONF['encrypt'] = 'cleartext';
// Mailboxes // If you want to store the mailboxes per domain set this to 'YES'. // Example: /usr/local/virtual/domain.tld/username@domain.tld $CONF['domain_path'] = 'YES'; // If you don't want to have the domain in your mailbox set this to 'NO'. // Example: /usr/local/virtual/domain.tld/username $CONF['domain_in_mailbox'] = 'NO';
// Quota // When you want to enforce quota for your mailbox users set this to 'YES'. $CONF['quota'] = 'YES'; $CONF['quota_multiplier'] = '1048576';