如何部署WebMail Roundcube?

WebMail

1 基础知识

1.1 Roundcub的简介

– Roundcub是一个免费的开源WebMail解决方案
– Roundcub具有类似桌面的用户界面,易于安装/配置
– Roundcub运行于标准的LAMPP服务器环境
– Roundcub外观使用最新的Web标准以及可自定义UI

1.2 Roundcub依赖的库

– PEAR
– IlohaMail
– IMAP
– TinyMCE(富文本编辑器)
– Googiespell(拼写检查)
– Masterminds的HTML5-PHP清理程序

1.3 Roundcub的功能

1.3.1 现有功能

– 支持多语言(支持70多种)
– 支持拖放邮件管理
– 支持完全支持MIME和HTML消息
– 支持精密的隐私保护
– 支持带附件的邮件
– 支持多发件人身份
– 支持组或者LDAP连接器的全功能地址簿
– 支持便利的查找地址簿集成
– 支持Richtext或HTML消息编写
– 支持转发带附件的邮件
– 支持搜索邮件或者联系人
– 支持线程消息列表
– 支持IDNA
– 支持拼写检查
– 支持预设响应模板
– 支持IMAP文检夹管理
– 支持外部的SMTP服务器
– 支持访问控制列表(ACL)
– 支持内置缓存,可实现快速邮箱访问
– 支持无限的用户和消息
– 支持导入导出功能
– 支持皮肤自定义模板系统
– 支持灵活的API插件扩展
– 支持PGP加密
– 支持三列视图

1.3.2 规划的功能

– 未来支持S/MIME加密
– 未来支持移动设备皮肤
– 未来支持附件预览
– 未来支持高级搜索所有文件夹
– 未来支持虚拟文件夹(保存搜索)
– 未来支持键盘快捷键
– 未来支持XCONVERSATIONS的对话视图
– 未来支持浏览器历史
– 未来支持在线日历模块
– 未来支持管理界面

1.4 部署环境要求

1.4.1 支持的Web服务器

– Apache
– Lighttpd
– Nginx
– Cherokee
– Hiawatha

1.4.2 脚本支持要求

允许在Web服务器的目录上运行脚本

1.4.3 PHP的要求

– PHP 5.4或更高版本
– 支持的组件
— PCRE(Perl兼容的正则表达式)
— DOM
— XML
— MBSTRING
— OpenSSL
— Session支持
— Socket支持
— PHP数据对象(PDO)、MySQL、PostgreSQL、SQL Server或SQLite的驱动程序
— Iconv(可选)
— FileInof(可选)
— ZIP(可选)
— Pspell(可选)

1.4.4 支持的数据库

– MySQL
– PostgreSQL
– SQLite
– MSSQL
– Oracle
注:MySQL或PostgreSQL,要求具有创建表和数据库用户的权限

1.4.5 Roundcube或外部的PEAR分发包

– Mail_Mime 1.10.0以上版本
– Net_SMTP 1.7.1以上版本
– Net_Socket 1.2.1以上版本
– Auth_SASL 1.1.0以上版本
– Net_Sieve 1.4.0以上版本(适用于manageieve插件)
– Crypt_GPG 16.1以上版本(适用于enigma插件)
– Net_LDAP2 2.2.0以上版本(适用于LDAP通讯录)
– kolab或Net_LDAP3 dev-master(适用于LDAP通讯录)

1.4.6 php.ini选项要求

– error_reporting E_ALL & ~E_NOTICE
– memory_limit选项要求 > 16MB(大附件支持)
– file_uploads选项启用(附件上传)
– session.auto_start选项禁用
– suhosin.session.encrypt选项禁用
– mbstring.func_overload选项禁用
– magic_quotes_runtime选项禁用
– magic_quotes_sybase选项禁用

1.4.7 邮件服务器要求

– IMAP 4 rev 1的IMAP服务器
– 支持SMTP服务器

1.4.8 支持的浏览器

– Internet Explorer 10 (Windows 7)
– Internet Explorer 11 (Windows 8)
– Microsoft Edge (Windows 10)
– Safari 9+ (Mac OS X)
– Firefox 4+ (Windows XP, Linux)
– Firefox 30+ (Windows, Mac OS X, Linux)
– Google Chrome 52+ (Mac OS X, Windows, Linux)

1.4.9 经过测试的浏览器

– Internet Explorer 10 (Windows 8)
– Internet Explorer 9 (Windows 7)
– Internet Explorer 8 (Windows XP/7,从Roundcube 1.1起需要legacy_browser插件)
– Internet Explorer 7 (Windows XP,从Roundcube 1.1起需要legacy_browser插件)
– Safari 3+ (Mac OS X 10.5 and Windows XP)
– Firefox 3.6 (Windows XP, Linux,从Roundcube 1.1起需要legacy_browser插件)
– Firefox 4+ (Windows, Linux)
– Google Chrome 9+ (Mac OS X, Windows 7, Linux)

1.5 支持的组件

– Kolab,可提供完整的电子邮件群组服务器,包括LDAP地址簿、日历、任务、移动同步等

2 最佳实践

2.1 环境配置

2.1.1 系统环境配置

hostname = roundcube.cmdschool.org
ip address = 10.168.0.100

2.1.2 辅助工具的安装

yum install -y vim wget unzip

2.1.3 部署LNMP环境

请参阅以下文档部署LNMP环境,
https://www.cmdschool.org/archives/1
注:PHP FastCGI请使用编译方式安装

2.1.4 下载安装包

wget https://github.com/roundcube/roundcubemail/releases/download/1.3.4/roundcubemail-1.3.4.tar.gz

其他版本请从如下链接下载,
https://github.com/roundcube/roundcubemail/releases

2.2 部署roundcube

2.2.1 部署源代码

mkdir -p /var/www/mail.cmdschool.org
cd ~
tar -xf roundcubemail-1.3.4.tar.gz
mv roundcubemail-1.3.4/* /var/www/mail.cmdschool.org/
chown -R apache:nginx /var/www/mail.cmdschool.org/
chmod -R 774 /var/www/mail.cmdschool.org/

2.2.2 配置数据库权限

mysql -uroot -p
create database roundcubemail;
grant all privileges on roundcubemail.* to roundcube@localhost identified by 'roundcubepwd';
flush privileges;

2.2.3 导入数据库结构

mysql -uroot -p -e 'use roundcubemail; source /var/www/mail.cmdschool.org/SQL/mysql.initial.sql;'

2.2.4 配置PHP

vim /etc/php.ini

加入如下配置:

memory_limit = 64M
display_errors = Off
log_errors = On
error_log = /var/log/php-fpm/error.log
upload_max_filesize = 5M
post_max_size = 6M
zlib.output_compression = Off
suhosin.session.encrypt = Off
session.auto_start = Off
session.gc_maxlifetime = 21600
session.gc_divisor = 500
session.gc_probability = 1
date.timezone = "Asia/Shanghai"

2.2.5 配置虚拟服务器

vim /etc/nginx/conf.d/mail.cmdschool.org_80.conf

加入如下配置:

server {
    listen       80;
    server_name  mail.cmdschool.org;

    charset koi8-r;
    access_log  /var/log/nginx/mail.access.log  main;

    location / {
        root   /var/www/mail.cmdschool.org;
        index  index.html index.htm index.php;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /var/www/mail.cmdschool.org;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        /etc/nginx/fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

重载是配置生效:

systemctl reload nginx

2.3 运行安装向导

http://mail.cmdschool.org/installer/
注:以上域名请配置DNS或者hosts记录,否则无法访问,访问后的页面显示如下,

2.4 使用composer安装必须的扩展

2.4.1 安装的常见错误和解决方法

缺少openssl扩展的错误提示,

  [Composer\Exception\NoSslException]
  The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl
  extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.

缺少git命令的错误提示

  [RuntimeException]
  Failed to clone https://git.kolab.org/diffusion/PNL/php-net_ldap.git, git was not found, check that it is install
  ed and in your PATH env.

  sh: git: command not found

缺少mbstring扩展包的错误提示

requirements could not be resolved to an installable set of packages.

  Problem 1
    - pear/crypt_gpg v1.6.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - pear/crypt_gpg v1.6.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - pear/crypt_gpg v1.6.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - pear/crypt_gpg v1.6.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - Installation request for pear/crypt_gpg ~1.6.0 -> satisfiable by pear/crypt_gpg[v1.6.0, v1.6.1, v1.6.2, v1.6.3].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.

缺少gd扩展包的错误提示

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - endroid/qrcode 1.6.6 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - endroid/qrcode 1.6.5 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - Installation request for endroid/qrcode ~1.6.5 -> satisfiable by endroid/qrcode[1.6.5, 1.6.6].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.

所以,为了解决以上错误提示,我们需要安装依赖的库

yum install -y openssl-devel gd-devel

修正内核文件的路径,

ln -s /usr/lib64/libssl.so /usr/lib/

手动安装GD(yum安装无法解决),
https://www.cmdschool.org/archives/2779
重新预编译PHP,

cd ~/php-7.1.12		
./configure --bindir=/usr/sbin/ \
            --sbindir=/usr/sbin/ \
            --sysconfdir=/etc/ \
            --libdir=/usr/lib64/  \
            --mandir=/usr/share/man/ \
            --includedir=/usr/include/ \
            --with-fpm-user=apache \
            --with-fpm-group=apache \
            --enable-fpm \
            --with-mysqli \
            --with-openssl=/usr \
            --enable-mbstring \
            --with-gd=/usr

重新编译并安装PHP,

make
make install

2.4.2 配置composer

cd /var/www/mail.cmdschool.org/
wget https://getcomposer.org/download/1.7.1/composer.phar

2.4.3 创建composer配置

cd /var/www/mail.cmdschool.org/
cp composer.json-dist composer.json

2.4.4 下载扩展组件

cd /var/www/mail.cmdschool.org/
sudo -u apache php -c /etc/php.ini composer.phar install --no-dev

2.4.5 安装JS组件

cd /var/www/mail.cmdschool.org/
./bin/install-jsdeps.sh

2.5 安装其他的扩展

以下扩展可根据实际情况选用,并非都是必选

2.5.1 安装工具扩展库

yum安装可安装的扩展库:

yum install -y openldap-devel libwebp-devel libjpeg-turbo-devel libXpm-devel freetype-devel libicu-devel

2.5.2 安装imagick扩展库

https://www.cmdschool.org/archives/2795
注:yum无法安装,需要自行编译

2.5.3 修正内核文件的路径

ln -s /usr/lib64/libldap.so /usr/lib/

2.5.4 重新预编译PHP

cd ~/php-7.1.12		
./configure --bindir=/usr/sbin/ \
            --sbindir=/usr/sbin/ \
            --sysconfdir=/etc/ \
            --libdir=/usr/lib64/  \
            --mandir=/usr/share/man/ \
            --includedir=/usr/include/ \
            --with-fpm-user=apache \
            --with-fpm-group=apache \
            --enable-fpm \
            --with-mysqli \
            --with-openssl=/usr \
            --enable-mbstring \
            --with-gd=/usr \
            --enable-intl \
            --enable-exif \
            --with-ldap=/usr \
            --with-webp-dir=/usr \
            --with-jpeg-dir=/usr \
            --with-xpm-dir=/usr \
            --with-freetype-dir=/usr \
            --with-pdo-mysql

2.5.5 重新编译并安装PHP

			
make
make install

注:如果执行“make”有如下错误提示,

/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_scanf'
/usr/lib64/liblber-2.4.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

请按如下方法处理,

vim Makefile

以下变量加入如下参数,

EXTRA_LIBS = -llber

2.5.6 加载imagick扩展

echo 'extension=imagick.so' >> /etc/php.ini

2.5.7 重启服务使配置生效

systemctl restart php-fpm.service

2.6 链接配置

2.6.1 生成配置文件

http://mail.cmdschool.org/installer/
完成之前的步骤,向导可以单击【next】,根据向导完成配置后可单击【Download】即可得到配置文件

2.6.2 链接数据库

vim /var/www/mail.cmdschool.org/config/config.inc.php

配置如下(即下载的配置文件):

<?php

/* Local configuration for Roundcube Webmail */

// ----------------------------------
// SQL DATABASE
// ----------------------------------
// Database connection string (DSN) for read+write operations
// Format (compatible with PEAR MDB2): db_provider://user:password@host/database
// Currently supported db_providers: mysql, pgsql, sqlite, mssql, sqlsrv, oracle
// For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php
// NOTE: for SQLite use absolute path (Linux): 'sqlite:////full/path/to/sqlite.db?mode=0646'
//       or (Windows): 'sqlite:///C:/full/path/to/sqlite.db'
$config['db_dsnw'] = 'mysql://roundcube:roundcubepwd@127.0.0.1/roundcubemail';

// ----------------------------------
// IMAP
// ----------------------------------
// The IMAP host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
//          required to match old user data records with the new host.
$config['default_host'] = 'imap.cmdschool.org';

// ----------------------------------
// SMTP
// ----------------------------------
// SMTP server host (for sending mails).
// Enter hostname with prefix tls:// to use STARTTLS, or use
// prefix ssl:// to use the deprecated SSL over SMTP (aka SMTPS)
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['smtp_server'] = 'smtp.cmdschool.org';

// provide an URL where a user can get support for this Roundcube installation
// PLEASE DO NOT LINK TO THE ROUNDCUBE.NET WEBSITE HERE!
$config['support_url'] = '';

// This key is used for encrypting purposes, like storing of imap password
// in the session. For historical reasons it's called DES_key, but it's used
// with any configured cipher_method (see below).
$config['des_key'] = 'a2Q10vuvP9QOeaHV6AtLais9';

// ----------------------------------
// PLUGINS
// ----------------------------------
// List of active plugins (in plugins/ directory)
$config['plugins'] = array();

2.6.3 链接后的检查

访问如下链接,
http://mail.cmdschool.org/
如果看到如下界面则基本配置完成,

参阅文档
===================

文档首页
——————-
https://github.com/roundcube/roundcubemail/wiki

修改配置文件
——————-
https://github.com/roundcube/roundcubemail/wiki/Configuration
https://distortion.io/git/mirror/roundcube/tree/de8687f9f11d49d36b322af72f644f7c5a232b9f/config

项目简介:
————-
https://roundcube.net/about/

官方配置向导:
————-
https://github.com/roundcube/roundcubemail/wiki/Installation

下载链接:
—————
https://github.com/roundcube/roundcubemail/releases

用户手册:
—————-
http://docs.roundcube.net/doc/help/1.1/en_US/

没有评论

发表回复

WebMail
如何部署Roundcube imapsync插件?

1 基础知识 1.1 Roundcube imapsync 1.1.1 基本概念 – R …

WebMail
如何安装Roundcube的全局通讯录?

1 简介 地址簿,提供丰富的界面来管理你的联系人信息(保存或访问你个人或共享的地址簿) 2 最佳实践 …

WebMail
如何部署WebMail Roundcube官方移动版?

1 基础知识 1.1 前言 Roundcube Webmail 1.4-beta是具有里程碑性质的一 …