FreeBSD 15

Apache httpd : Web メール : RoundCube2026/01/23

 

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

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

+----------------------+          |          +----------------------+
|  [  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 稼働サーバーに PHP をインストールしておきます。

[5]

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

[6]

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

[7] Create a Database for RoundCube.
root@www:~ #
mariadb

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 11.8.5-MariaDB FreeBSD Ports

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] の箇所は設定したいパスワードに置き換え
root@localhost [(none)]> create database roundcubemail; 
Query OK, 1 row affected (0.00 sec)

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

root@localhost [(none)]> exit 
[8] Install and Configure RoundCube.
root@www:~ #
pkg install -y roundcube-php83
root@www:~ #
cd /usr/local/www/roundcube/SQL

root@www:/usr/local/www/roundcube/SQL #
mariadb -u roundcube -D roundcubemail -p < mysql.initial.sql

Enter password:  
# MariaDB roundcube パスワード

root@www:/usr/local/www/roundcube/SQL #
cd

root@www:~ #
cp -p /usr/local/www/roundcube/config/config.inc.php.sample /usr/local/www/roundcube/config/config.inc.php

root@www:~ #
vi /usr/local/www/roundcube/config/config.inc.php
// 28行目 : DB 接続情報を設定
$config['db_dsnw'] = 'mysql://roundcube:password@127.0.0.1/roundcubemail';

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

// 36行目 : SMTP サーバーを指定
$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';

root@www:~ #
vi /usr/local/etc/apache24/Includes/roundcube.conf
# 新規作成
Alias /roundcube /usr/local/www/roundcube
<Directory /usr/local/www/roundcube>
    DirectoryIndex index.php
    Options +FollowSymLinks
    AllowOverride All
    Require all granted
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/"
    </FilesMatch>
</Directory>

<Directory /usr/local/www/roundcube/config>
    Options -FollowSymLinks
    AllowOverride None
</Directory>

<Directory /usr/local/www/roundcube/temp>
    Options -FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/local/www/roundcube/logs>
    Options -FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

root@www:~ #
service php_fpm reload

root@www:~ #
service apache24 reload
[9] Access to [https://(your server's hostname or IP address/)/roundcube/], then Roundcube login form is shown, authenticate with any user on Mail Server.
[10] After successfully logined, verify possible to send or receive emails normally.
関連コンテンツ