作者 主題: [教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟  (閱讀 27139 次)

0 會員 與 1 訪客 正在閱讀本文。

olderboy

  • 憂鬱的高中生
  • ***
  • 文章數: 100
    • 檢視個人資料
小弟我,在網路上找了許久,才將這個部份實作出來的~~現在就 post 我安裝的步驟給各位大大分享一下~~

但是小弟我還是有個問題~~就是 Cyrus-SASL 的 SMTP  認證~~
我還是無法成功的使用~~
如有那位大大成功的安裝在一起的話!!還請告訴我喔!!謝謝~~


Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟

1.安裝MySQL

請到 http://www.mysql.com/downloads/download.php?file=Downloads%2FMySQL-3.23%2Fmysql-3.23.56.tar.gz&mirror=http%3A%2F%2Fgd.tuwien.ac.at%2Fdb%2Fmysql%2F 下載 MySQL

[root@dns local]# tar zxvf mysql-3.23.56.tar.gz
[root@dns local]# cd mysql-3.23.56
[root@dns mysql-3.23.56]# ./configure --prefix=/usr/local/mysql --with-charset=big5
[root@dns mysql-3.23.56]# make
[root@dns mysql-3.23.56]# make install
[root@dns mysql-3.23.56]# ./script/mysql_install_db
[root@dns mysql-3.23.56]# /usr/local/mysql/share/mysql/mysql.server start
[root@dns mysql-3.23.56]# /usr/local/mysql/bin/mysqladmin -uroot password xxxxxx


到此,MySQL安裝完畢囉!!

2.MySQL SETUP

2-1.Create the database

USE mysql;
INSERT INTO user (Host, User, Password) VALUES ('localhost','postfix',password('postfix'));
INSERT INTO db (Host, Db, User, Select_priv) VALUES ('localhost','postfix','postfix','Y');
CREATE DATABASE postfix;

2-2.Create the Alias Table

USE postfix;
CREATE TABLE alias (
  address varchar(255) NOT NULL default '',
  goto text NOT NULL,
  domain varchar(255) NOT NULL default '',
  create_date datetime NOT NULL default '0000-00-00 00:00:00',
  change_date datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(4) NOT NULL default '1',
  PRIMARY KEY (address)
) TYPE=MyISAM COMMENT='Virtual Aliases - mysql_virtual_alias_maps';

2-3.Create the Domain Table

USE postfix;
CREATE TABLE domain (
  domain varchar(255) NOT NULL default '',
  description varchar(255) NOT NULL default '',
  create_date datetime NOT NULL default '0000-00-00 00:00:00',
  change_date datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(4) NOT NULL default '1',
  PRIMARY KEY (domain)
) TYPE=MyISAM COMMENT='Virtual Domains - mysql_virtual_domains_maps';

2-4.Create the Mailbox Table

USE postfix;
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 '',
  domain varchar(255) NOT NULL default '',
  create_date datetime NOT NULL default '0000-00-00 00:00:00',
  change_date datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(4) NOT NULL default '1',
  PRIMARY KEY (username)
) TYPE=MyISAM COMMENT='Virtual Mailboxes - mysql_virtual_mailbox_maps';


3.安裝SASL

請到 ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.13.tar.gz 下載
[root@dns local]# tar zxvf cyrus-sasl-2.1.13.tar.gz
[root@dns local]# cd cyrus-sasl-2.1.13
[root@dns cyrus-sasl-2.1.13]# ./configure --with-mysql=/usr/local/mysql/
[root@dns cyrus-sasl-2.1.13]# make
[root@dns cyrus-sasl-2.1.13]# make install
[root@dns cyrus-sasl-2.1.13]# ln -s /usr/local/lib/sasl2 /usr/lib/sasl2


4.安裝Postfix

請到 ftp://postfix.cdpa.nsysu.edu.tw/postfix/postfix-release/official/postfix-2.0.9.tar.gz 下載
請先編緝 /etc/ld.so.conf 加入
/usr/local/mysql/lib/mysql
/usr/local/lib
[root@dns local]# ldconfig
[root@dns local]# tar zxvf postfix-2.0.9.tar.gz
[root@dns local]# cd postfix-2.0.9
[root@dns postfix-2.0.9]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -I/usr/local/include/sasl' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/lib -lsasl2'
[root@dns postfix-2.0.9]# make
[root@dns postfix-2.0.9]# make install
[root@dns postfix-2.0.9]# mkdir /usr/local/virtual
[root@dns postfix-2.0.9]# chown -R 1001:1001 /usr/local/virtual
[root@dns postfix-2.0.9]# chmod -R 751 /usr/local/virtual


5.設定Postfix

main.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:1001
virtual_mailbox_base = /usr/local/virtual
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_limit = 51200000
virtual_transport = virtual
virtual_uid_maps = static:1001

5-1.mysql_virtual_alias_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address

5-2.mysql_virtual_domains_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = domain
select_field = description
where_field = domain

5-3.mysql_virtual_mailbox_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username


6.安裝 Courier-IMAP

請到 http://umn.dl.sourceforge.net/sourceforge/courier/courier-imap-1.7.2.tar.bz2 下載
[root@dns local]# bunzip2 courier-imap-1.7.2.tar.bz2
[root@dns local]# tar xvf courier-imap-1.7.2.tar
[root@dns local]# cd courier-imap-1.7.2
[root@dns courier-imap-1.7.2]# ./configure --disable-root-check --without-authuserdb --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authvchkpw --without-authpgsql --without-authcram --without-authcustom --without-authdaemon --with-mysql-libs=/usr/local/mysql/lib/mysql/ --with-mysql-includes=/usr/local/mysql/include/mysql/ --with-authmysql
[root@dns courier-imap-1.7.2]# make
[root@dns courier-imap-1.7.2]# make install


7.編緝 Courier-IMAP

7-1.authmysqlrc

DEFAULT_DOMAIN          domain.tld
MYSQL_CRYPT_PWFIELD     password
MYSQL_DATABASE          postfix
MYSQL_GID_FIELD         1001
MYSQL_HOME_FIELD        '/usr/local/virtual'
MYSQL_LOGIN_FIELD       username
MYSQL_MAILDIR_FIELD     maildir
MYSQL_NAME_FIELD        name
MYSQL_OPT               0
MYSQL_PASSWORD          postfix
# MYSQL_PORT            0
# MYSQL_QUOTA_FIELD     quota
MYSQL_SERVER            localhost
# MYSQL_SOCKET          /var/mysql/mysql.sock
MYSQL_UID_FIELD         1001
MYSQL_USERNAME          postfix
MYSQL_USER_TABLE        mailbox
# MYSQL_WHERE_CLAUSE    server='mailhost.example.com'


8.安裝 Postfix Admin

請到 http://www.high5.net/howto/postfixadmin-1.5.0-5.tgz 下載
[root@dns htdocs]# tar zxvf postfixadmin-1.5.0-5.tgz

8-1.Postfix Admin Install

[root@dns local]# /usr/local/mysql/bin/mysql -uroot -pxxxxxx
mysql> USE mysql
mysql> INSERT INTO user (Host, User, Password) VALUES ('localhost','postfixadmin',password('postfixadmin'));
mysql> INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('localhost', 'postfix', 'postfixadmin', 'Y', 'Y', 'Y', 'Y');

8-2.Postfix Admin Setup

[root@dns local]# /usr/local/mysql/bin/mysql -uroot -pxxxxxx
mysql> USE postfix;
mysql> CREATE TABLE admin (
mysql> username varchar(255) NOT NULL default '',
mysql> password varchar(255) NOT NULL default '',
mysql> domain varchar(255) NOT NULL default '',
mysql> create_date datetime NOT NULL default '0000-00-00 00:00:00',
mysql> change_date datetime NOT NULL default '0000-00-00 00:00:00',
mysql> active tinyint(4) NOT NULL default '1',
mysql> PRIMARY KEY (username)
mysql> ) TYPE=MyISAM COMMENT='Virtual Admins - Store Virtual Domain Admins';

himaruko

  • 懷疑的國中生
  • **
  • 文章數: 38
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #1 於: 2004-08-25 12:35 »
請問一下,我在安裝Courier-IMAP的時候

./configure --disable-root-check --without-authuserdb --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authvchkpw --without-authpgsql --without-authcram --without-authcustom --without-authdaemon --with-mysql-libs=/usr/local/mysql/lib/mysql/ --with-mysql-includes=/usr/local/mysql/include/mysql/ --with-authmysql

這個步驟有錯[Cannot find either the gdbm or the db library.]

另外在make及make install時也會產生錯誤[make: *** No targets specified and no makefile found.  Stop.]

因為不太熟,可不可以請問您是什麼原因 .... :oops:

olderboy

  • 憂鬱的高中生
  • ***
  • 文章數: 100
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #2 於: 2004-09-07 22:09 »
引述: "himaruko"
請問一下,我在安裝Courier-IMAP的時候

./configure --disable-root-check --without-authuserdb --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authvchkpw --without-authpgsql --without-authcram --without-authcustom --without-authdaemon --with-mysql-libs=/usr/local/mysql/lib/mysql/ --with-mysql-includes=/usr/local/mysql/include/mysql/ --with-authmysql

這個步驟有錯[Cannot find either the gdbm or the db library.]

另外在make及make install時也會產生錯誤[make: *** No targets specified and no makefile found.  Stop.]

因為不太熟,可不可以請問您是什麼原因 .... :oops:



看到這個訊息,該是你的linux有一些套件沒有安裝上去吧!!
像是:gdbm之類的套件
你試著找出這個套件安裝上去,該就可以了~

himaruko

  • 懷疑的國中生
  • **
  • 文章數: 38
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #3 於: 2004-09-08 10:15 »
依照您的方法安裝gdbm等套件後,問題已經解決
但是,仍然出現下列錯誤訊息:

Sep 7 10:54:12 openmail postfix/master[1340]: warning: process /usr/libexec/postfix/smtpd pid 1354 exit status 1

Sep 7 10:54:12 openmail postfix/master[1340]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

請問您有類似的問題嗎?

olderboy

  • 憂鬱的高中生
  • ***
  • 文章數: 100
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #4 於: 2004-09-08 12:44 »
引述: "himaruko"
依照您的方法安裝gdbm等套件後,問題已經解決
但是,仍然出現下列錯誤訊息:

Sep 7 10:54:12 openmail postfix/master[1340]: warning: process /usr/libexec/postfix/smtpd pid 1354 exit status 1

Sep 7 10:54:12 openmail postfix/master[1340]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

請問您有類似的問題嗎?



這個訊息,該是postfix的main.cf沒設定好所造成的,可否post上來你在main.cf裡的設定內容呢??

himaruko

  • 懷疑的國中生
  • **
  • 文章數: 38
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #5 於: 2004-09-08 13:31 »
謝謝你的回覆喔!!我的master檔:

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd
#smtps    inet  n       -       n       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes
#submission     inet    n       -       n       -       -       smtpd
#  -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes
#submission     inet    n       -       n       -       -       smtpd
#  -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes
#628      inet  n       -       n       -       -       qmqpd
pickup    fifo  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
#qmgr      fifo  n       -       n       300     1       qmgr
qmgr     fifo  n       -       n       300     1       nqmgr
#tlsmgr   fifo  -       -       n       300     1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
smtp      unix  -       -       n       -       -       smtp
relay     unix  -       -       n       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
#
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# maildrop. See the Postfix MAILDROP_README file for details.
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
#
# The Cyrus deliver program has changed incompatibly, multiple times.
#
old-cyrus unix  -       n       n       -       -       pipe
  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
# Cyrus 2.1.5 (Amos Gouaux)
cyrus     unix  -       n       n       -       -       pipe
  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient

himaruko

  • 懷疑的國中生
  • **
  • 文章數: 38
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #6 於: 2004-09-08 14:13 »
我看錯了,以為您要的是master.cf,再重po一次main.cf的,sorry!! :oops:

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = 000.xxx.xxx.tw
mydomain = xxx.xxx.tw
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname
unknown_local_recipient_reject_code = 450
mynetworks = 140.xxx.xxx.xxx/32, 127.0.0.1/8
alias_maps = mysql:/etc/postfix/mysql-alias.cf
home_mailbox = Mailbox
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.0.11/samples
readme_directory = /usr/share/doc/postfix-2.0.11/README_FILES
alias_database = hash:/etc/postfix/aliases
local_recipient_maps = mysql:/etc/postfix/mysql-local.cf
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,
                               reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous

我後來沒有採用courier-imap的方式,因為我要使用openwebmail,所以我用qpop

olderboy

  • 憂鬱的高中生
  • ***
  • 文章數: 100
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #7 於: 2004-09-09 11:08 »
引述: "himaruko"
我看錯了,以為您要的是master.cf,再重po一次main.cf的,sorry!! :oops:

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = 000.xxx.xxx.tw
mydomain = xxx.xxx.tw
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname
unknown_local_recipient_reject_code = 450
mynetworks = 140.xxx.xxx.xxx/32, 127.0.0.1/8
alias_maps = mysql:/etc/postfix/mysql-alias.cf
home_mailbox = Mailbox
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.0.11/samples
readme_directory = /usr/share/doc/postfix-2.0.11/README_FILES
alias_database = hash:/etc/postfix/aliases
local_recipient_maps = mysql:/etc/postfix/mysql-local.cf
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,
                               reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous

我後來沒有採用courier-imap的方式,因為我要使用openwebmail,所以我用qpop


原來你是使用qpop,而不是採用 courier-imap 喔!那在 main.cf 裡設定的,我看是沒有出現什麼錯誤才對,是否要查一下跟 qpop 整合時所需要的設定,那設定錯了,剩下來的,我就無法提供給你任何的資訊了~

alibaba.will

  • 可愛的小學生
  • *
  • 文章數: 8
    • 檢視個人資料
我也在順利安裝完成後遇到問題
« 回覆 #8 於: 2007-03-01 21:25 »
您好:我在如列進行安裝完成後,但是不知該如何啟動courier-imap的服務?POP3的服務又該在哪啟動呢?
謝謝!

alibaba.will

  • 可愛的小學生
  • *
  • 文章數: 8
    • 檢視個人資料
[教學]Postfix+Courier-IMAP+MySQL+Cyrus-SASL 安裝步驟
« 回覆 #9 於: 2007-03-06 17:33 »
繼續提出問題
在安裝後  會出現下列訊息是怎麼一回事呢
procmail: Couldn't create "/var/mail/nobody"