openSUSE Leap 16

Apache httpd : Web メール : RoundCube2025/12/03

 

RoundCube をインストールして Web メールシステムを構築します。

当例では以下のような環境を例にします。
メールサーバーはローカルネットワーク内の別ホストのメールサーバーを利用するよう設定します。
またバックエンドでデータベースを使用するため、MySQL, SQLite, PostgreSQL のいずれかがインストール済みである必要があります。
当例では MariaDB を利用するよう設定します。

また、前提として、SUSE の RoundCube パッケージの依存関係で、PHP は mod_php での稼働が必要となり、そのためには Apache httpd は prefork で稼働している必要があります。

+----------------------+          |          +----------------------+
|  [  www.srv.world  ] |10.0.0.31 | 10.0.0.32|  [ mail.srv.world  ] |
|     Apache httpd     +----------+----------+        Postfix       |
|      (Roundcube)     |                     |        Dovecot       |
|       MariaDB        |                     |                      |
+----------------------+                     +----------------------+

[1]

こちらを参考に SMTP サーバーをインストールしておきます

[2]

こちらを参考に IMAP サーバーをインストールしておきます

[3]

こちらを参考に SMTP/IMAP サーバー共に SSL/TLS の設定を実施しておきます。(必須ではないが推奨)

[4]

こちらを参考に httpd 稼働サーバーに SSL/TLS の設定を実施しておきます。(必須ではないが推奨)

[5]

こちらを参考に httpd 稼働サーバーに MariaDB サーバーをインストールしておきます

[6] RoundCube 用のデータベースを作成しておきます。
www:~ #
mariadb

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 76
Server version: 11.8.3-MariaDB MariaDB package

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

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

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

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

MariaDB [(none)]> exit
Bye
[7] RoundCube のインストールと設定です。
Apache httpd は prefork で稼働している必要があります。
www:~ #
zypper -n install roundcubemail php8 php8-mysql apache2-mod_php8
www:~ #
cd /usr/share/doc/packages/roundcubemail/SQL

www:/usr/share/doc/packages/roundcubemail/SQL #
mariadb -u roundcube -D roundcubemail -p < mysql.initial.sql

Enter password:  
# MariaDB roundcube パスワード

www:/usr/share/doc/packages/roundcubemail/SQL #
www:~ #
cp -p /etc/roundcubemail/config.inc.php.sample /etc/roundcubemail/config.inc.php

www:~ #
vi /etc/roundcubemail/config.inc.php
// 28行目 : データベース接続情報を設定
$config['db_dsnw'] = 'mysql://roundcube:password@localhost/roundcubemail';

// 32行目 : IMAP サーバーを指定 (STARTTLS 接続)
$config['imap_host'] = 'tls://mail.srv.world:143';

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

// 40行目 : 確認 (SMTP 認証に IMAP 認証と同じユーザーを利用)
$config['smtp_user'] = '%u';

// 44行目 : 確認 (SMTP 認証に IMAP 認証と同じパスワードを利用)
$config['smtp_pass'] = '%p';

// 51行目 : 表示画面のタイトルを変更可
$config['product_name'] = 'Server World Webmail';

// 最終行に追記
// 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',
  ),
);

www:~ #
vi /etc/apache2/conf.d/roundcubemail.conf
# 27行目 : 必要に応じてアクセス許可 IP を追記
# * デフォルトはローカルホストのみ許可

Require ip 10.0.0.0/24
www:~ #
systemctl reload apache2

[8] SELinux を有効にしている場合は、ポリシーの許可設定が必要です。
www:~ #
setsebool -P httpd_can_network_connect on

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