ブログ ランキング
インターネットサーバー設定・運用
HOME  | MYBlog  | MAIL 

dovecot のインストール

SSL をサポートした IMAP/POP3 サーバー

環境

 
dovecot-1.2.4
Solaris 10 5/09 x86
VMware Server 1.0.8
 

SSL に対応させる場合は openssl が必要です。  ここでは OS をインストールして入った openssl-0.9.7d を利用します。

インストール

dovecot のサイト から dovecot-1.2.4.tar.gz をダウンロードして任意の場所で解凍

$ gzip -dc dovecot-1.2.4.tar.gz | tar xvf -
$ cd dovecot-1.2.4
$ export PATH=$PATH:/usr/ccs/bin:/usr/sfw/bin
$ CPPFLAGS=-I/usr/sfw/include/openssl LDFLAGS=-L/usr/sfw/lib ./configure
$ make
$ make test
$ su
# make install
# groupadd dovecot
# useradd -g dovecot -s /bin/false -d /dev/null dovecot

■設定

まずは非SSL の設定です。

# cd /usr/local/etc
# cp dovecot-example.conf dovecot.conf   雛形をコピー
# vi dovecot.conf
protocols = imap pop3

protocol pop3 {
   listen = *:110
    }

protocol imap {
   listen = *:143
   }
   
disable_plaintext_auth = no

mail_location = mbox:~/mail:INBOX=/var/mail/%u

mail_privileged_group = mail

first_valid_uid = 0

dovecot の起動

# /usr/local/sbin/dovecot

プロセスの確認

# ps -ef|grep dovecot
 dovecot   624   612   0 23:09:46 ?           0:00 pop3-login
    root   612     1   0 23:09:45 ?           0:01 /usr/local/sbin/dovecot
    root   613   612   0 23:09:45 ?           0:00 dovecot-auth
    root   620   612   0 23:09:46 ?           0:00 dovecot-auth -w
 dovecot  1222   612   0 23:17:02 ?           0:00 pop3-login
  msaito  1309  1207   0 00:33:02 pts/3       0:00 grep dove
 dovecot   630   612   0 23:09:47 ?           0:00 imap-login
 dovecot   632   612   0 23:09:47 ?           0:00 imap-login
 dovecot  1230   612   0 23:19:17 ?           0:00 imap-login
 dovecot  1220   612   0 23:17:01 ?           0:00 pop3-login

オプション "-n" で設定内容を表示

# /usr/local/sbin/dovecot -n

/etc/init.d/dovecot起動スクリプトの作成

# License is public domain.

DAEMON=/usr/local/sbin/dovecot

test -x $DAEMON || exit 1
set -e

base_dir=`$DAEMON -a|grep '^base_dir: '|sed 's/^base_dir: //'`
pidfile=$base_dir/master.pid

if test -f $pidfile; then
  running=yes
else
  running=no
fi

case "$1" in
  start)
    echo -n "Starting Dovecot"
    $DAEMON
    echo "."
    ;;
  stop)
    if test $running = yes; then
      echo "Stopping Dovecot"
      kill `cat $pidfile`
      echo "."
    else
      echo "Dovecot is already stopped."
    fi
    ;;
  reload)
    if test $running = yes; then
      echo -n "Reloading Dovecot configuration"
      kill -HUP `cat $pidfile`
      echo "."
    else
      echo "Dovecot isn't running."
    fi
    ;;
  restart|force-reload)
    echo -n "Restarting Dovecot"
    if test $running = yes; then
      kill `cat $pidfile`
      sleep 1
    fi
    $DAEMON
    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/dovecot \
    {start|stop|reload|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0

リンクの作成

# ln /etc/init.d/dovecot /etc/rc2.d/S86dovecot
# ln /etc/init.d/dovecot /etc/rc2.d/K86dovecot
# ln /etc/init.d/dovecot /etc/rc1.d/K86dovecot
# ln /etc/init.d/dovecot /etc/rc0.d/K86dovecot

SSL 化の設定

サーバー証明書の作成

# cd dovecot-1.2.4/doc
# vi dovecot-openssl.cnf   サーバー証明書作成の設定ファイルを修正

[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no

[ req_dn ]
# country (2 letter code)
#C=FI

# State or Province Name (full name)
#ST=

# Locality Name (eg. city)
#L=Helsinki

# Organization (eg. company)
#O=Dovecot

# Organizational Unit Name (eg. section)
OU=IMAP server

# Common Name (*.example.com is also possible)
CN=imap.example.com

# E-mail contact
emailAddress=postmaster@example.com

[ cert_type ]
nsCertType = server

# ./mkcert.sh

設定

# vi /usr/local/etc/dovecot.conf
protocols = imap imaps pop3 pop3s

protocol pop3 {
   listen = *:110
   ssl_listen = *:995
    }

protocol imap {
   listen = *:143
   ssl_listen = *:993
   }

ssl = yes

ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem