Linux 技术手札

安装 PHP Ajax Webmail — Roundcube

Roundcube 是 PHP 的 Ajax Webmail, 功能完善而且接口漂亮, 我觉得 Roundcube 的中文处理能力很好, 很多以前在 SquirrelMail 乱码的邮件, 在 Roundcube 都可以看到。Roundcube 是使用数据库作为后台储存数据, 而且只支援 IMAP 通讯协定。下面以 CentOS 6 为例, 会下载 Roundcube 的源码直接安装:

1. 建立 LAMP 环境, 可以参考 RHEL 及 CentOS 7 安装 Apache, MariaDB, PHP(LAMP).

2. 安装 Roundcube

# cd /var/www
# wget http://jaist.dl.sourceforge.net/project/roundcubemail/roundcubemail/1.1.1/roundcubemail-1.1.1-complete.tar.gz
# tar zxvf roundcubemail-1.1.1-complete.tar.gz
# rm roundcubemail-1.1.1-complete.tar.gz
# mv roundcubemail-1.1.1 html/roundcube

上面会下载 Roundcube 1.1.1, 并解压到 /var/www/html/roundcube.

3. 设定权限:

chown root:root -R /var/www/html/roundcube
chmod 777 -R /var/www/html/roundcube/temp/
chmod 777 -R /var/www/html/roundcube/logs/

4. 下一步是设定 Apache, 开启 httpd.conf 并加入以下内容:

Alias /webmail /var/www/html/roundcube
<Directory /var/www/html/roundcube>
   Options -Indexes
   AllowOverride All
</Directory>
<Directory /var/www/html/roundcube/config>
   Order Deny,Allow
   Deny from All
</Directory>
<Directory /var/www/html/roundcube/temp>
   Order Deny,Allow
   Deny from All
</Directory>
<Directory /var/www/html/roundcube/logs>
   Order Deny,Allow
   Deny from All
</Directory>

上会除了定义存取权限外, 还会将 Roundcube 指向 /webmail, 加入以上内容后, 重新启动 Apache.

5. 建立 Roundcube 的数据库及 MySQL 使用者, 先用 root 登入 MySQL:

mysql -u root -p
mysql> CREATE DATABASE roundcube_db;
mysql> CREATE USER ‘rcmail’@’localhost’ IDENTIFIED BY ‘rc_password’;
mysql> GRANT ALL PRIVILEGES ON roundcube_db.localhost TO ‘rcmail’@’localhost’;
mysql> FLUSH PRIVILEGES;
mysql> exit;

上面会建立给 Roundcube 使用的数据库及权限, 分别是:

数据库名称: roundcube_db
使用者名称: rcmail
使用者密码: rc_password
连接主机: localhost

以上资料请根据需要进行修改.

6. 最后一步是设定 Roundcube, 先将 Roundcube 的初始 SQL 档汇入 Roundcube 的数据库:

# mysql -u root -p ‘rcmail’ < /var/www/html/roundcube/SQL/mysql.initial.sql

汇入 Roundcube 的 SQL 档后, 设定 Roundcube 的 MySQL 登入资料,

# cp /var/www/html/roundcube/config/config.inc.php.sample /var/www/html/roundcube/config/config.inc.php
# rm -rf /var/www/html/roundcube/installer

开启上面复制的 /var/www/html/roundcube/conf/config.inc.php, 找到 $config[‘db_dsnw’], 改成这样:

这样就可以透过主机名称后面加上 /webmail 存取 Roundcube, 例如 http://localhost/webmail.

Exit mobile version