作業系統: CentOS 6.3 x64 with Minimal installation

硬體環境: 2 Core CPU with 2GB RAM (on VMware ESXi 4.1)

 

Mantis + Dokuwiki + Subversion + Active Directory - Part 1

安裝 Mantis, 並透過 Active Directory 認證

 

1. 安裝 Linux 套件與設定服務

# 安裝套件 (httpd, mysql, php, openssl)
yum -y install mysql-server httpd php php-ldap php-xml php-mysql php-gd php-mbstring mod_ssl openssl 

# 設定服務於開機時自動啟動 (httpd, mysql) 
chkconfig --level 345 httpd on 
chkconfig --level 345 mysqld on 

# 打開防火牆 80/TCP, 443/TCP
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
iptables-save > /etc/sysconfig/iptables

# 設定可以從 httpd 寄信
setsebool -P httpd_can_sendmail=1

# 修改 php.ini
cd /etc
cp php.ini php.ini.`date +"%Y%m%d%H%M%S"`
sed -i 's/memory_limit = 128M/memory_limit = 512M/g' php.ini
sed -i 's/post_max_size = 8M/post_max_size = 20M/g' php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/g' php.ini
sed -i 's/;date.timezone =/date.timezone = "Asia\/Taipei"/g' php.ini

# 手動重新啟動服務 (httpd, mysql) 
service httpd restart 
service mysqld restart

2. 建立資料庫

 
#
# 假設:
# 1. 資料庫名稱是 mantis_db
# 2. 資料庫帳號名稱是 mantis_user@localhost
# 3. 資料庫帳號密碼是 qwgcerefxefxx
#
cat << EOF | mysql 
create database mantis_db; 
create user 'mantis_user'@'localhost' identified by 'qwgcerefxefxx'; 
grant all on mantis_db.* to 'mantis_user'@'localhost'; 
flush privileges; 
EOF

3. 下載 Mantis

#
# 假設:
# 欲下載的 Mantis 版本是 1.2.10, 檔名是 mantisbt-1.2.10.tar.gz
#
cd ~
wget http://sourceforge.net/projects/mantisbt/files/mantis-stable/1.2.10/mantisbt-1.2.10.tar.gz/download
cd /var/www/html
tar -xvzf ~/mantisbt-1.2.10.tar.gz
mv mantisbt-1.2.10 mantis

4. 編輯 Mantis 設定檔

#
# 假設:
# 1. Mantis 網址名稱是: http://mantis.mycompany.com/mantis/
# 2. SMTP Host/IP: 192.168.1.2
# 3. Admin/WebMaster Email: bugmaster@mycompany.com

# 設定語系, 避免產生 config_inc.php 時產生中文亂碼
LANG=zh_TW.big5

# 產生 config_inc.php
cat << EOF > /var/www/html/mantis/config_inc.php
<?php
    # 基本設定
    \$g_path = 'https://mantis.mycompany.com/mantis/';     # Mantis URL
    \$g_default_language = 'chinese_traditional';          # 繁體中文為預設語系
    \$g_window_title = 'My Issue Management System';       # Mantis 的 Title
    
    # 資料庫設定
    \$g_db_type = 'mysql';
    \$g_database_name = 'mantis_db';
    \$g_db_username = 'mantis_user';
    \$g_db_password = 'qwgcerefxefxx';
    
    # 日期格式設定
    \$g_short_date_format = 'Y/m/d';
    \$g_normal_date_format = 'Y/m/d H:i';
    \$g_complete_date_format = 'Y/m/d H:i';
    
    # 上傳檔案大小與預覽的限制
    \$g_max_file_size = 20000000;                      # 20MB
    \$g_preview_attachments_inline_max_size = 5000000; # 圖檔
    # 傳送通知郵件的設定
    \$g_administrator_email  = 'bugmaster@mycompany.com';
    \$g_webmaster_email      = 'bugmaster@mycompany.com';
    \$g_from_email           = 'bugmaster@mycompany.com';
    \$g_return_path_email    = 'bugmaster@mycompany.com';
    \$g_phpMailer_method     = 2;                          # 用 SMTP 寄信
    \$g_smtp_host = '192.168.1.2';                         # SMTP Hostname or IP
    \$g_enable_email_notification = ON;
?>
EOF

# 設定 /var/www/html/mantis 的 user.group
chown -R apache.apache /var/www/html/mantis

5. 建立 Mantis Database Schema

  • 以瀏覽器瀏覽網址 https://<mantis 的 hostname or ip/mantis/admin/install.php
  • 檢查右邊都是綠色的 GOOD (除了 Config File Exists but Database does not 之外), 如下圖
  • 按最下面的 "Install/Upgrade Database" 按鈕
  • 經過悉里呼嚕一瞬間之後會顯示安裝結果, 檢查右邊都是綠色的 GOOD (除了 Set Admin Username 與 Set Admin Password 之外), 如下圖
  • 點最下面的 "Continue to log into Mantis"

 Install Mantis  

Install Mantis Result  

6. 移除 admin 目錄

登入畫面會有兩個警告訊息, 提醒我們要:

  • 移除 /var/www/html/mantis/admin 目錄
  • 以 administrator 登入後, 要先改密碼

First login Mantis  

# 移除 /var/www/html/mantis/admin 目錄
rm -rf /var/www/html/mantis/admin

7. 以 Administrator 登入 Mantis 並改變帳號密碼

  • 以帳號 Administrator, 密碼 root 登入 Mantis
  • 點主選單的 "管理"
  • 點 "管理使用者"
  • 點 "administrator"
  • 將帳號改名稱, 例如改為 MantisAdmin, 同時重設密碼 ( !!*** 請注意 ***!! 這個新的帳號, 必須存在於 Windows Domain (Active Directory), 否則後面改為 Window Domain 認證後, 會無法登入!!)

Mantis Management

 Mantis Manage Users  

Mantis Manage Administrator

Mantis Change Admin   

8. 整合 Windows Domain (Active Directory) 認證

#
# 假設:
# Windows AD Server: 192.168.1.1
# Windows 隨便一個 Domain User: MyCompanyDomain\OneDomainUser
# Windows 上面這個 Domain User 的密碼是: rtcgxqxcwrgcfr
# Windows AD 裡面的帳號都放在 Users 這個 CN 底下: cn=users,dc=mycompany,dc=com
cd /var/www/html/mantis
cp config_inc.php config_inc.php.`date +"%Y%m%d%H%M%S"`
sed -i 's/?>//g' config_inc.php
cat << EOF >> config_inc.php
    # Windows 網域認證 (Active Directory)
    \$g_login_method = LDAP;
    \$g_ldap_server = 'ldap://192.168.1.1/';
    \$g_ldap_port = 389;
    \$g_ldap_root_dn = 'cn=Users,dc=mycompany,dc=com';
    \$g_ldap_bind_dn = 'MyCompanyDomain\OneDomainUser';
    \$g_ldap_bind_passwd = 'rtcgxqxcwrgcfr';
    # 自動以 Windows Domain 的 Email 為 Mail
    \$g_use_ldap_email = ON;
    \$g_ldap_uid_field = 'sAMAccountName';
    \$g_ldap_organisation = '';
    \$g_ldap_protocol_version = 3;
    # 既然已經使用 AD 認證, 乾脆就把登入畫面 "註冊新帳號" 的連結拿掉
    \$g_allow_signup = OFF;
    # 既然已經使用 AD 認證, 登入畫面的 "忘記密碼" 也拿掉吧
    \$g_send_reset_password = OFF;
?>
EOF

9. 測試登入

  • 以 Mantis Administrator (本範例是改為 MantisAdmin) 以及 Windows Domain 的密碼登入

Mantis Login Screen 2  


10. 建立新的使用者


只要用 Windows Domain 的帳號與密碼登入, Mantis 會自動建立新的使用者, 並賦予 Reporter 的權限, 因此不需要 Administrator 再手動建立. 惟若有專案的需要比較高的機密, 則該專案應該設定為 "非公開", 並明確指定哪些帳號才有權限, 以避免任意的 Domain User 登入後都可以看到所有專案的內容

arrow
arrow
    全站熱搜

    Egg Chang 發表在 痞客邦 留言(1) 人氣()