Debian 11 Bullseye
Sponsored Link

Apache2 : Web メール : RoundCube2021/09/15

 
RoundCube をインストールして Web メールシステムを構築します。
当例では以下のような環境で、メールサーバーは同一ネットワーク内の別ホストを利用するように設定します。
またバックエンドでデータベースを使用するため、MySQL, SQLite, PostgreSQL のいずれかがインストール済みである必要があります。
当例では MySQL 互換の MariaDB を利用するよう設定します。
+----------------------+          |          +----------------------+
|  [  www.srv.world  ] |10.0.0.31 | 10.0.0.32|  [ mail.srv.world  ] |
|     Apache httpd     +----------+----------+        Postfix       |
|      (Roundcube)     |                     |        Dovecot       |
|       MariaDB        |                     |                      |
+----------------------+                     +----------------------+

[1]
[2]
[3]
[4]
[5]
[6]
[7] RoundCube 用のデータベースを作成しておきます。
root@www:~#
mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 50
Server version: 10.5.11-MariaDB-1 Debian 11

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# [roundcube] データベース作成
# [password] の箇所は設定したいパスワードに置き換え
MariaDB [(none)]> create database roundcube; 
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on roundcube.* to roundcube@'localhost' identified by 'password'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit 
Bye
[8] RoundCube のインストールと設定です。
root@www:~#
apt -y install roundcube roundcube-mysql
# データベースの設定は後ほど手動実行するため [No] で OK

 +----------------------+ Configuring roundcube-core +-----------------------+
 |                                                                           |
 | The roundcube package must have a database installed and configured       |
 | before it can be used.  This can be optionally handled with               |
 | dbconfig-common.                                                          |
 |                                                                           |
 | If you are an advanced database administrator and know that you want to   |
 | perform this configuration manually, or if your database has already      |
 | been installed and configured, you should refuse this option.  Details    |
 | on what needs to be done should most likely be provided in                |
 | /usr/share/doc/roundcube.                                                 |
 |                                                                           |
 | Otherwise, you should probably choose this option.                        |
 |                                                                           |
 | Configure database for roundcube with dbconfig-common?                    |
 |                                                                           |
 |                    <Yes>                       <No>                       |
 |                                                                           |
 +---------------------------------------------------------------------------+

root@www:~#
cd /usr/share/dbconfig-common/data/roundcube/install

root@www:/usr/share/dbconfig-common/data/roundcube/install#
mysql -u roundcube -D roundcube -p < mysql

Enter password:  
# MariaDB roundcube パスワード

root@www:/usr/share/dbconfig-common/data/roundcube/install#
root@www:~#
vi /etc/roundcube/debian-db.php
# データベース情報を設定

$dbuser='
roundcube
';
$dbpass='
password
';
$basepath='';
$dbname='
roundcube
';
$dbserver='localhost';
$dbport='3306';
$dbtype='
mysql
';
root@www:~#
vi /etc/roundcube/config.inc.php
# 36行目 : IMAP サーバーを指定 (STARTTLS 接続)

$config['default_host'] = 'tls://mail.srv.world';
# 48行目 : SMTP サーバーを指定 (STARTTLS 接続)

$config['smtp_server'] = 'tls://mail.srv.world';
# 51行目 : SMTP ポート変更 (STARTTLS 接続)

$config['smtp_port'] = 587;
# 55行目 : 変更 (SMTP 認証に IMAP 認証と同じユーザーを利用)

$config['smtp_user'] = '%u';
# 59行目 : 変更 (SMTP 認証に IMAP 認証と同じパスワードを利用)

$config['smtp_pass'] = '%p';
# 66行目 : 変更 (表示画面のタイトル)

$config['product_name'] = 'Server World Webmail';
# 最終行に追記

# IMAP ポート指定 (STARTTLS 接続)
$config['default_port'] = 143;

# SMTP 認証タイプを指定
$config['smtp_auth_type'] = 'LOGIN';

# SMTP HELO host を指定
$config['smtp_helo_host'] = 'mail.srv.world';

# ドメイン名を指定
$config['mail_domain'] = 'srv.world';

# UserAgent を指定
$config['useragent'] = 'Server World Webmail';

# SMTP と IMAP の接続オプションを指定
$config['imap_conn_options'] = array(
  'ssl'         => array(
    'verify_peer' => true,
    'CN_match' => 'srv.world',
    'allow_self_signed' => true,
    'ciphers' => 'HIGH:!SSLv2:!SSLv3',
  ),
);
$config['smtp_conn_options'] = array(
  'ssl'         => array(
    'verify_peer' => true,
    'CN_match' => 'srv.world',
    'allow_self_signed' => true,
    'ciphers' => 'HIGH:!SSLv2:!SSLv3',
  ),
);

root@www:~#
vi /etc/apache2/conf-enabled/roundcube.conf
# 3行目 : コメント解除

Alias /roundcube /var/lib/roundcube/public_html
# 11行目 : 必要であればアクセス許可変更

Require
ip 127.0.0.1 10.0.0.0/24
root@www:~#
systemctl restart apache2
[9] アクセス許可したネットワーク内の任意のクライアントコンピューターで Web ブラウザーを起動し、[https://(サーバーのホスト名 または IP アドレス)/roundcube/] にアクセスします。 すると RoundCube のログイン画面が表示されるので、メールサーバー側に登録済みの任意のユーザーでログインします。
[10] 正常にログインした後は、メールの送受信テストを実施して、動作に問題ないか確認しておくとよいでしょう。
関連コンテンツ