Postfixを使ったメールサーバ構築.5/dovecot2の設定、システムの起動

さて、引き続きpostfixでのメールサーバ構築です。
今回はdovecot2のインストール、設定となります。
これでとりあえずメールサーバは構築完了かと思います。

By: Nori Norisa
dovecotですが、現在、Scientific Linuxでyumからインストール出来るバージョンは2.0.9です。
ですので、今回はこのバージョンを使います。
では、yumでインストールします。
この時、mysqlパッケージがあるのであれば、一緒にインストールしておきます。
develパッケージはインストールしなくてもいいですが、容量に余裕があればインストールしておく方がいろいろいいでしょう。。
[bash]
# yum –enablerepo=remi,rpmforge,epel list | grep dovecot
dovecot.x86_64 1:2.0.9-2.el6_1.1 sl
dovecot.i686 1:2.0.9-2.el6_1.1 sl
dovecot-devel.x86_64 1:2.0.9-2.el6_1.1 sl
dovecot-devel.i686 1:2.0.9-2.el6_1.1 sl
dovecot-mysql.x86_64 1:2.0.9-2.el6_1.1 sl
dovecot-pgsql.x86_64 1:2.0.9-2.el6_1.1 sl
dovecot-pigeonhole.x86_64 1:2.0.9-2.el6_1.1 sl
# yum –enablerepo=remi,rpmforge,epel install dovecot.x86_64 dovecot-devel.x86_64 dovecot-mysql.x86_64
[/bash]
設定ファイル関係は”/etc/dovecot/”内にあります。
dovecot 1.xでは”/etc/dovecot/dovecot.conf”だけを編集すればよかったのですが、今回のバージョンから”/etc/dovecot/dovecot.conf”は基本的な設定のみで、ほとんどの設定は”/etc/dovecot/conf.d/”配下のファイルで行うようになっています。
では、それぞれ変更が必要なファイルと内容を記述していきます。
/etc/dovecot/dovecot.conf
[bash]
# 最初の"protocols"だけ、自分が使うプロトコルに変更します
# 分からない場合は下記3つにしておけば間違いないです
protocols = imap pop3 lmtp
[/bash]
/etc/dovecot/dovecot-mysql.conf
新規で作成するファイルになります。
このファイルが認証の鍵になりますので、慎重に作って下さい。
途中の”/home/vmail”は自身が指定したメールボックス用のフォルダを記述します。
[bash]
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=パスワード
default_pass_scheme = MD5-CRYPT
# following should all be on one line.
password_query = SELECT password FROM mailbox WHERE username = ‘%u’ AND active = ‘1’
# following should all be on one line
user_query = SELECT concat(‘/home/vmail/’, maildir) AS home, 101 AS uid, 12 AS gid FROM mailbox WHERE username = ‘%u’ AND active = ‘1’
[/bash]
/etc/dovecot/conf.d/10-auth.conf
[bash]
# 認証時のパスワードについて、暗号化するかどうかなどを指定します
# 最近はcram-md5が多いようですね
auth_mechanisms = cram-md5
#
# 今回はSQLでの認証ですので、下記のコメントを外しておきます
!include auth-sql.conf.ext
[/bash]
/etc/dovecot/conf.d/10-mail.conf
[bash]
# メールボックスの場所を指定します
# %d : ドメイン名 %n : ユーザ名(ドメイン含まず)
mail_location = maildir:/home/vmail/%d/%n
[/bash]
/etc/dovecot/conf.d/10-master.conf
[bash]
# 使用するプロトコルのコメントを外します。
# 私の場合、下記のような設定にしました。
service imap-login {
inet_listener imap {
port = 143
}
inet_listener imaps {
port = 993
ssl = yes
}
# Number of connections to handle before starting a new process. Typically
# the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0
# is faster. <doc/wiki/LoginProcess.txt>
#service_count = 1
# Number of processes to always keep waiting for more connections.
#process_min_avail = 0
# If you set service_count=0, you probably need to grow this.
#vsz_limit = 64M
}
service pop3-login {
inet_listener pop3 {
port = 110
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
# また、これ以外にも下記もコメント除去及び設定変更しています
service auth {
# auth_socket_path points to this userdb socket by default. It’s typically
# used by dovecot-lda, doveadm, possibly imap process, etc. Its default
# permissions make it readable only by root, but you may need to relax these
# permissions. Users that have access to this socket are able to get a list
# of all usernames and get results of everyone’s userdb lookups.
unix_listener auth-userdb {
mode = 0666
user = vmail
group = mail
}
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
# Auth process is run as this user.
#user = $default_internal_user
}
service dict {
# If dict proxy is used, mail processes should have access to its socket.
# For example: mode=0660, group=vmail and global mail_access_groups=vmail
unix_listener dict {
mode = 0600
user = vmail
group = mail
}
}
[/bash]
/etc/dovecot/conf.d/10-ssl.conf
[bash]
# 今回、SSL認証を行うので、下記を"yes"に変更します
ssl = yes
#
# crt/keyを指定します。指定するときの頭の"<"は必要なようです
ssl_cert = </etc/httpd/conf/ドメイン名.crt
ssl_key = </etc/httpd/conf/ドメイン名.key
[/bash]
/etc/dovecot/conf.d/20-etc.conf
[bash]
dict {
quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf
}
[/bash]
/etc/dovecot/conf.d/90-plugin.conf
このファイルは新規で作成しました
[bash]
plugin {
#setting_name = value
quota = dict:user::proxy::quotadict
acl = vfile:/etc/dovecot/acls
trash = /etc/dovecot/trash.conf
sieve_global_path = /home/sieve/globalfilter.sieve
sieve = ~/dovecot.sieve
sieve_dir = ~/sieve
sieve_global_dir = /home/sieve/
#sieve_extensions = +notify +imapflags
sieve_max_script_size = 1M
#sieve_max_actions = 32
#sieve_max_redirects = 4
}
[/bash]
/etc/dovecot/conf.d/auth-sql.conf.ext
それぞれmysqlでの認証になりますので、先程作成した認証用のファイルを指定します。
[bash]
passdb {
driver = sql
args = /etc/dovecot/dovecot-mysql.conf
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-mysql.conf
}
[/bash]
これで設定は一通り完了です。
ここまで設定が完了したら各プログラムを動かしてみましょう。
mysqlは再起動してみた方がいいかもしれません。
[bash]
# /etc/init.d/mysqld restart
# /etc/init.d/postfix restart
# /etc/init.d/dovecot start
[/bash]
ブラウザからpostfixadminを起動してみて、ドメインの登録が出来るかどうか確認してみて下さい。
また、メールアドレスが生成できるかどうかも一緒に確認しましょう。
後はDNSの設定を行い、メールの送受信テストを行います。

Share this post