安裝 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.

Tags:

Leave a Reply