OshiHa.com

ConoHaでAlpine Linux 3.8

Dovecot のインストール・設定

2018/09/02  2018/09/03

◆◇◆ 【衝撃価格】VPS512MBプラン!月額630円/1時間1円【ConoHa】 ◆◇◆

Dovecot をインストールして IMAPサーバーを構築する。(今回はPOPサーバーは構築しない。)

1. インストール

alpine:~$ sudo apk add dovecot

2. Dovecot のバージョン確認

alpine:~$ dovecot --version
2.3.2.1 (0719df592)

3. Dovecot の設定

設定1

alpine:~$ sudo cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.org
alpine:~$ sudo vi /etc/dovecot/dovecot.conf
## Dovecot configuration file

protocols = imap
!include_try /usr/share/dovecot/protocols.d/*.conf

listen = *

!include conf.d/*.conf
!include_try local.conf

設定2

alpine:~$ sudo cp /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.org
alpine:~$ sudo vi /etc/dovecot/conf.d/10-master.conf
service imap-login {
  inet_listener imap {
    port = 0
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}

service pop3-login {
  inet_listener pop3 {
    port = 0
  }
  inet_listener pop3s {
    port = 0
   # ssl = yes
  }
}

service auth {
  unix_listener auth-userdb {
  }

  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    user = postfix
    group = postfix
  }
}

設定3

alpine:~$ sudo cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.org
alpine:~$ sudo vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir

namespace inbox {

  inbox = yes

}

設定4

alpine:~$ sudo cp /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.org
alpine:~$ sudo vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no

auth_mechanisms = plain login

#!include auth-deny.conf.ext
#!include auth-master.conf.ext

!include auth-passwdfile.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-system.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

設定5

alpine:~$ sudo cp /etc/dovecot/conf.d/auth-passwdfile.conf.ext /etc/dovecot/conf.d/auth-passwdfile.conf.ext.org
alpine:~$ sudo vi /etc/dovecot/conf.d/auth-passwdfile.conf.ext
passdb {
  driver = passwd-file
  args = /etc/dovecot/passwd
}

userdb {
  driver = passwd-file
  args = /etc/dovecot/passwd
}
alpine:~$ sudo doveadm pw -s HMAC-MD5
Enter new password:
Retype new password:
{HMAC-MD5}**************************************************
alpine:~$ sudo vi /etc/dovecot/passwd
ユーザー名:{HMAC-MD5}**************************************************:1000:1000::/home/ユーザー名

設定6

alpine:~$ sudo cp /etc/dovecot/conf.d/10-logging.conf /etc/dovecot/conf.d/10-logging.conf.org
alpine:~$ sudo vi /etc/dovecot/conf.d/10-logging.conf
# ログファイルの場所を明記
log_path = /var/log/dovecot/dovecot.log

ログの出力先を作成
alpine:~$ sudo mkdir /var/log/dovecot

設定7

DH鍵交換に使用するパラメータファイルを指定する。
この dhparam.pem は OpenSSLコマンドで生成できる。
alpine:~$ sudo cp /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.org
alpine:~$ sudo vi /etc/dovecot/conf.d/10-ssl.conf

ssl = yes

ssl_cert = </etc/letsencrypt/live/mail.oshiha.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.oshiha.com/privkey.pem

ssl_dh = </etc/dovecot/dh.pem

ssl_min_protocol = TLSv1

ssl_prefer_server_ciphers = yes
alpine:~$ sudo openssl dhparam -out /etc/dovecot/dh.pem 4096

4. Dovecot の起動とサービス登録

alpine:~$ sudo rc-service dovecot start
alpine:~$ sudo rc-update add dovecot

◆◇◆ 【衝撃価格】VPS512MBプラン!月額630円/1時間1円【ConoHa】 ◆◇◆

ConoHa VPSの攻略
Alpine Linux 3.8

TOP