2010/03/18

[ LOS ] CentOS Install Ajax Webmail Roundcube

寫下紀錄這是最近所安裝的東西,要如何在 CentOS 5.4 Linux 中安裝 Postfix + Roundcube Ajax Webmail ?


1. 安裝 Postfix + Dovecot

# netstat -nutlp |grep 25      # 查看原本 25 port 服務預設都是 sendmail
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      2098/sendmail: acce
udp        0      0 fe80::250:4ff:fec3:7d59:123 :::*                                    2403/ntpd

# service sendmail stop
正在關閉 sm-client:                                        [  確定  ]
正在關閉 sendmail:                                         [  確定  ]

# chkconfig sendmail off     # 關閉 sendmail
# chkconfig sendmail --list      # 查看是否關閉
sendmail        0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:關閉  6:關閉

# yum -y install postfix       # 安裝另一套 Mail  Transfer Agent (MTA)  postfix

# vi /etc/postfix/main.cf      # 設定 postfix 主設定檔
myhostname = mail.xxx.com.tw    # 設定本機的 host name
mydomain = xxx.com.tw   # 設定 domain 網域
mynetworks = 10.99.99.0/24, 127.0.0.0/8    # 設定幫忙可 relay 的 hosts
inet_interfaces = all    # 設定服務 interface
#inet_interfaces = localhost    #這一行加上# 號才能對外做 SMTP 服務
mydestination = xxx.com.tw   # 設定本機要接收的 mail, 同 sendmail 的 local-host-names
home_mailbox = Maildir/   # 開啟使用 Maildor 格式

# postalias hash:/etc/aliases     # 建立 aliases db
# postmap hash:/etc/postfix/access     # 建立 access db

# alternatives --config mta     # 更改系統 MTA
有 2 程式提供 'mta'。
  選擇        指令
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.sendmail
   2           /usr/sbin/sendmail.postfix
請輸入以保留目前的選擇[+],或輸入選擇號碼: 2

# chkconfig postfix on   # 設定開機啟動 postfix
# chkconfig postfix --list     # 查看開機啟動 postfix

postfix         0:關閉  1:關閉  2:開啟  3:開啟  4:開啟  5:開啟  6:關閉
# service postfix start     # 啟動 postfix
正在啟動 postfix:                                          [  確定  ]
# netstat -ntulp | grep :25     # 再次查看 25 port
tcp        0      0 0.0.0.0:25                0.0.0.0:*                   LISTEN      15949/master

# yum -y install dovecot     # 安裝 dovecot
# vi /etc/dovecot.conf      # 設定 dovecot
protocols = imap imaps pop3 pop3s
mail_location = maildir:~/Maildir
pop3_uidl_format = %08Xu%08Xv
# Required on x86_64 kernels
login_process_size = 64

# chkconfig dovecot on    # 設定開機啟動 dovecot
# chkconfig dovecot --list      # 查看開機啟動 dovecot
dovecot         0:關閉  1:關閉  2:開啟  3:開啟  4:開啟  5:開啟  6:關閉

# service dovecot start    # 手動啟動 dovecot
正在啟動 Dovecot Imap:                                     [  確定  ]
# netstat -ntulp |grep tcp    # 查看 dovecot 所開的四個 port
tcp        0      0 :::993                      :::*                        LISTEN      16023/dovecot
tcp        0      0 :::995                      :::*                        LISTEN      16023/dovecot
tcp        0      0 :::110                      :::*                        LISTEN      16023/dovecot
tcp        0      0 :::143                      :::*                        LISTEN      16023/dovecot
# mkdir /home/jim/Maildir     # 建立使者 Maildir 目錄,用以存放 mail
# chown jim.jim /home/jim/Maildir     # 修改擁有者


2. 升級 PHP 到 5.2.x 版之後版本

※ 這是因為我安裝的roundcube1.3.1版要求的,而原本 CentOS 5.4 中 yum 所裝的PHP為5.1.6版

# vi /etc/yum.repos.d/CentOS-Base.repo    # 新增測試版 Server 套件庫
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/5/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
# yum update php*  # 更新升級套件

# php -v    # 查看升級後版本
PHP 5.2.10 (cli) (built: Nov 13 2009 11:24:03)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
# rpm -q php php-mysql php-pecl-Fileinfo php-mcrypt php-xml php-gd php-mbstring   # 查看安裝 roundcube 必安裝的 php 套件
php-5.2.10-1.el5.centos
php-mysql-5.2.10-1.el5.centos
php-pecl-Fileinfo-1.0.4-3.el5.centos
php-mcrypt-5.2.9-2.el5.centos.3
php-xml-5.2.10-1.el5.centos
php-gd-5.2.10-1.el5.centos
php-mbstring-5.2.10-1.el5.centos
# vi /etc/php.ini    # 查看 php 參數是否正確設定
file_uploads = On
session.auto_start = 0

3. 安裝 roundcube

※ 到官網http://www.roundcube.net下載最新版本 roundcubemail-0.3.1.tar.gz 套件到 Server 的 /var/www/html 中

# cd /var/www/html   # 切換目錄
# tar -xzvf roundcubemail-0.3.1.tar.gz   # 解壓縮套件
# mv roundcubemail-0.3.1 webmail   # 更改目錄名稱
# cd /var/www/html/webmail   # 切換目錄
# chown -R apache.apache logs temp   # 更改兩個目錄擁有者
# chmod 0700 logs temp  # 更改兩個目錄權限

# mysql -p    # 進入 mysql
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 163
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database roundcubemail;   # 建立 roundcubemail 這個資料庫
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcubemail@localhost IDENTIFIED BY 'Your-Password';  # 設roundcubemail這個資料庫權限
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;   # 立即更新
Query OK, 0 rows affected (0.00 sec)
mysql>exit   # 離開

# cd /var/www/html/webmail/SQL/    # 切換目錄
# mysql -u roundcubemail -p -h localhost roundcubemail < mysql.initial.sql   # 建立資料庫 roundcubemail 的 table
Enter password:
# cd /var/www/html/webmail/config/   # 切換目錄
# cp db.inc.php.dist db.inc.php     # copy DB 設定檔
# cp main.inc.php.dist main.inc.php   # copy 主設定檔

# vi db.inc.php   # 修改連接DB資訊
//$rcmail_config['db_dsnw'] = ‘mysql://帳號:密碼@localhost/資料庫名稱;  # 格式如左
$rcmail_config['db_dsnw'] = 'mysql://roundcubemail:Your-Password@localhost/roundcubemail';

# vi main.inc.php  # 修改主要設定檔

$rcmail_config['default_host'] = '10.99.99.8';   #郵件伺服器的位置或DNS名稱
$rcmail_config['mail_domain'] = 'xxx.com.tw';  #網域名稱
$rcmail_config['smtp_server'] = '10.99.99.8';      #郵件伺服器的位置或DNS名稱
$rcmail_config['auto_create_user'] = true;    # 自動 create user
$rcmail_config['create_default_folders'] = TRUE;    # 建立預設資料夾
$rcmail_config['language'] = ' zh_TW ';                 # 預設語系
$rcmail_config['timezone'] = '8';   # 時區台灣是8
$rcmail_config['default_charset'] = 'UTF-8';    # 預設編碼

http://Your-IP/webmail/installer   # 開個 Browse 查看安裝 roundcube 還缺哪些套件

# rm -rf /var/www/html/webmail/installer   # 如果完成安裝,為安全理由請移除安裝目錄

http://Your-IP/webmail/   # 整個安裝完成後使用帳號登入

Ref:
http://wiki.centos.org/HowTos/postfix
http://www.roundcube.net

Add:
http://www.linuxmail.info/poppassd-setup-howto-centos-5/   # 安裝 poppassd 修改密碼 Plugin 外掛方式

※ roundcube 中通訊錄匯出時為 UTF-8 編碼,若要轉為 Outlook 看得懂得格式請先用記事本將 rcube_contacts.vcf 轉存成 ANSI 編碼後再匯入。

0 意見: