1 views

実現する機能

Gmail、Hotmail、Yahoo!メール、そしてレンタルサーバーに来るメールすべてを自宅のメールサーバーで一覧、確認できるようにしています。使っているのはWebブラウザ上でメールができるWebmailシステムRoundcube Webmailです。CentOS 6.5 まで使っていたSquirrelMailは、CentOS 7.0 対応版がまだ出ていないようなので、待てずに乗り換えました。

事前準備

Webサーバーリポジトリの追加(RPMforge、EPEL)Webサーバー間通信内容暗号化メールサーバー(要IMAP)が構築済であること

Roundcube WebmailのDownload&Install

[root@ufuso plugins]# wget http://sourceforge.net/projects/roundcubemail/files/roundcubemail/1.0.2/roundcubemail-1.0.2.tar.gz
 ← roundcubemailをダウンロード
`roundcubemail-1.0.2.tar.gz' に保存中

100%[======================================>] 3,980,298   1.38MB/s 時間 2.8s   

2014-08-11 22:46:27 (1.38 MB/s) - `roundcubemail-1.0.2.tar.gz' へ保存完了 [3980298/3980298]

[root@ufuso plugins]# tar zxvf roundcubemail-1.0.2.tar.gz ← ファイルを展開
roundcubemail-1.0.2/
roundcubemail-1.0.2/.htaccess
roundcubemail-1.0.2/bin/
・・・
・・・
・・・
roundcubemail-1.0.2/bin/update.sh
roundcubemail-1.0.2/bin/updatecss.sh
roundcubemail-1.0.2/bin/updatedb.sh

[root@ufuso ~]# mv roundcubemail-*/ /var/www/roundcubemail ← 展開したファイルを
全てwwwフォルダ内に移動 

[root@ufuso ~]# chmod o+w /var/www/roundcubemail/temp/ ← tempフォルダに書き込み
権限を設定 

[root@ufuso ~]# chmod o+w /var/www/roundcubemail/logs/ ← logsフォルダに書き込み
権限を設定 

[root@ufuso ~]# rm -f roundcubemail-*.tar.gz ← ダウンロードファイルの削除 

[root@ufuso ~]# vi /var/www/roundcubemail/program/lib/Roundcube/rcube_charset.php
 ← rcube_charset.phpファイルの編集
        // convert charset using mbstring module
        if ($mbstring_list !== false) {
            $aliases['WINDOWS-1257'] = 'ISO-8859-13';
            $aliases['JIS'] = 'ISO-2022-JP-MS';
            $aliases['ISO-2022-JP'] = 'ISO-2022-JP-MS';
            $aliases['EUC-JP'] = 'EUCJP-WIN';
            $aliases['SJIS'] = 'SJIS-WIN';
            $aliases['SHIFT_JIS'] = 'SJIS-WIN'; ← Microsoft拡張文字セットを認識
させるよう修正
            // it happens that mbstring supports ASCII but not US-ASCII
            if (($from == 'US-ASCII' || $to == 'US-ASCII') && !in_array('US-ASCII', $mbstring_list)) {
                $aliases['US-ASCII'] = 'ASCII';
            }

[root@ufuso ~]# wget http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
 ← mime.typesダウンロードして、電子メールでさまざまなフォーマット(書式)を扱え
るようにする
`mime.types' に保存中

100%[======================================>] 53,009      69.5KB/s 時間 0.7s   

2014-08-11 23:32:05 (69.5 KB/s) - `mime.types' へ保存完了 [53009/53009]

[root@ufuso ~]# mv mime.types /var/www/roundcubemail/config/ ← mime.typesを
roundcubemailのconfigディレクトリへ移動 

[root@ufuso ~]# vi /var/www/roundcubemail/config/defaults.inc.php
 ← mdefaults.inc.phpファイルの編集 
// Absolute path to a local mime.types mapping table file.
// This is used to derive mime-types from the filename extension or vice versa.
// Such a file is usually part of the apache webserver. If you don't find a file named mime.types on your system,
// download it from http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
// $config['mime_types'] = null; ← //を付けて無効化
$config['mime_types'] = '/var/www/roundcubemail/config/mime.types';
 ← mime.typesの場所を指定

■Roundcube Webmailの設定

[root@ufuso ~]# yum -y install php-mysql php-xml ← php-mysql、php-xmlインスト
ール  
更新:
  php-mysql.x86_64 0:5.4.16-23.el7_0      php-xml.x86_64 0:5.4.16-23.el7_0     

依存性を更新しました:
  php.x86_64 0:5.4.16-23.el7_0          php-cli.x86_64 0:5.4.16-23.el7_0       
  php-common.x86_64 0:5.4.16-23.el7_0   php-devel.x86_64 0:5.4.16-23.el7_0     
  php-gd.x86_64 0:5.4.16-23.el7_0       php-mbstring.x86_64 0:5.4.16-23.el7_0  
  php-pdo.x86_64 0:5.4.16-23.el7_0      php-process.x86_64 0:5.4.16-23.el7_0   

完了しました!

[root@ufuso plugins]# mysql -u root -p ← MariaDBへログイン 
Enter password:  ← rootのパスワード入力 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> create database roundcubemail; ← データベース作成 
Query OK, 1 row affected (0.14 sec)

MariaDB [(none)]> grant all privileges on roundcubemail.* to ufuso@localhost identified by 'password';
 ← データベースの管理ユーザー作成 
Query OK, 0 rows affected (0.25 sec)

MariaDB [(none)]> exit ← MariaDBからログアウト 
Bye

[root@ufuso ~]# mysql -u ufuso -p roundcubemail < /var/www/roundcubemail/SQL/mysql.initial.sql ← データベースroundcubemailの初期化 
Enter password: ← ufusoのパスワード入力

[root@ufuso ~]# vi /etc/php.ini ← php.iniの編集
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

[CLI Server]
; Whether the CLI web server uses ANSI color coding in its terminal output.
cli_server.color = On

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = Asia/Tokyo ← メールの日時を日本時間で表示

[root@ufuso ~]# vi /var/www/roundcubemail/config/defaults.inc.php ← defaults.inc.phpの編集
// enforce connections over https
// with this option enabled, all non-secure connections will be redirected.
// set the port for the ssl connection as value of this option if it differs from the default 443
//$config['force_https'] = false; ← //を行頭に付けて無効化
$config['force_https'] = true; ← httpsアクセス(暗号化)を強制

// This domain will be used to form e-mail addresses of new users
// Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['mail_domain'] = 'ufuso.dip.jp'; ← 送信元メールアドレスの@以下を指定

[root@ufuso ~]# echo Alias /roundcubemail /var/www/roundcubemail > /etc/httpd/conf.d/roundcubemail.conf
 ← https://サーバー名/roundcubemail/でWebメールへアクセスできるようにする

[root@ufuso ~]# systemctl reload httpd ← httpdリロード(設定反映)   

■最終処理&SELinuxを有効にしている場合

[root@ufuso ~]# rm -rf /var/www/roundcubemail/installer/ ← installフォルダの削
除

[root@ufuso ~]#setsebool -P httpd_can_network_connect on ← Webからのネットワー
ク接続を許可

[root@ufuso ~]# ls -dZ /var/www/roundcubemail ← roundcubemailフォルダのSELinux
設定状況を確認
drwxr-xr-x. 501 80 unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/roundcubemail ← httpd_sys_content_tであればOK。でなければ、以下の処理を行うこと

[root@ufuso ~]# semanage fcontext -a -t httpd_sys_content_t "/var/www/roundcubemail(/.*)?"
 ← ウェブコンテンツとしてroundcubemailフォルダへのアクセスを許可

[root@ufuso ~]# restorecon -R -v /var/www/roundcubemail ← 変更設定を更新

[root@ufuso ~]# systemctl reload httpd ← httpdリロード(設定反映)

■root宛メールも確認出きるように転送する

[root@ufuso ~]#sed -i '/^root:/d' /etc/aliases ← 旧root宛メール転送設定削除
 
[root@ufuso ~]#  echo "root: ufuso@gmail.com" >> /etc/aliases ← root宛メールを
他のメルアド(ufuso@gmail.comは例示)宛に転送する。そして、gmailで自宅サーバーに転送
設定する
 
[root@ufuso ~]# newaliases ← 転送設定反映
 
[root@ufuso ~]# echo test|mail root ← テストメールをroot宛に送信する

■動作確認

1.http://サーバー名/roundcubemail/にアクセスして、ログイン名にはCentOSのユーザー名、パスワードにはユーザーパスワードを入力します。
roundcubemail00
2.受信画面が開けばOKです。testメールが受診されていますので、受信はOKです。送信ができるかも確認してください。
roundcubemail01

以上

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください