Mantis + Dokuwiki + Subversion + Active Directory - Part 4
Install Subversion & WebSVN (Apache httpd + Active Directory Authentication)
1. 安裝 Subversion
# # 用 yum 簡單的安裝 Subversion # yum -y install subversion mod_dav_svn # # 假設: # 1. Subversion 的 repository 都放在 /var/www/svn 底下 # 2. 建立一個 test repository # mkdir -p /var/www/svn svnadmin create /var/www/svn/test chown -R apache.apache /var/www/svn
2. 設定 Apache httpd, 並使用 Active Directory 認證
建立 /etc/httpd/conf.d/subversion.conf
# # 假設: # 1. Windows AD Server: 192.168.1.1 # 2. Windows 隨便一個 Domain User: MyCompanyDomain\OneDomainUser # 3. Windows 上面這個 Domain User 的密碼是: rtcgxqxcwrgcfr # 4. Windows AD 裡面的帳號都放在 Users 這個 CN 底下: cn=users,dc=mycompany,dc=com # cd /etc/httpd/conf.d cp subversion.conf subversion.conf.`date +"%Y%m%d%H%M%S"` cat << EOF > subversion.conf LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <Location "/svn/"> SSLRequireSSL on Require valid-user DAV svn SVNParentPath /var/www/svn SVNListParentPath on SVNAutoversioning on AuthBasicProvider ldap AuthType Basic AuthzLDAPAuthoritative on AuthName "Subversion Repository" AuthLDAPURL "ldap://192.168.1.1:389/cn=Users,dc=mycompany,dc=com?sAMAccountName?sub?(objectClass=person)" NONE AuthLDAPBindDN "MyCompanyDomain\OneDomainUser" AuthLDAPBindPassword rtcgxqxcwrgcfr AuthzSVNAccessFile /etc/svn/accessfile </Location> EOF # # 重新啟動 httpd (subversion.conf 有任何修改, 都必須重新啟動 httpd) # service httpd restart
建立 /etc/svn/accessfile
# # 讓任何 Domain User 皆有 Read 的權限 # mkdir -p /etc/svn cd /etc/svn cat << EOF > accessfile [/] * = r EOF
測試是否可以正常運作
- 打開瀏覽器輸入網址 https://<mantis's hostname or ip>/svn/ (註: svn 後面一定要有 "/")
- 瀏覽器會彈出認證視窗, 請輸入任一個 Windows Domain User
3. 安裝 WebSVN
# # 假設 WebSVN 版本是 2.3.3, 檔名是 websvn-2.3.3.tar.gz # cd ~ wget http://websvn.tigris.org/files/documents/1380/49056/websvn-2.3.3.tar.gz cd /var/www/html tar -xvzf ~/websvn-2.3.3.tar.gz mv websvn-2.3.3 websvn chown -R apache.apache websvn
建立 /etc/httpd/conf.d/websvn.conf
# # 假設: 認證授權的設定都跟上面的 Subversion 一樣 # cd /etc/httpd/conf.d cat << EOF > websvn.conf <Location /websvn/> SSLRequireSSL on AuthType Basic AuthName "Subversion Repository" Require valid-user AuthBasicProvider ldap AuthType Basic AuthzLDAPAuthoritative on AuthName "Subversion Repository" AuthLDAPURL "ldap://192.168.1.1:389/cn=Users,dc=mycompany,dc=com?sAMAccountName?sub?(objectClass=person)" NONE AuthLDAPBindDN "MyCompanyDomain\OneDomainUser" AuthLDAPBindPassword rtcgxqxcwrgcfr AuthzSVNAccessFile /etc/svn/accessfile </Location> EOF
建立 /var/www/html/websvn/include/config.php
cd /var/www/html/websvn/include cp distconfig.php config.php cat << EOF >> config.php $config->setSVNCommandPath('/usr/bin'); $config->parentPath('/var/www/svn'); $config->useAuthenticationFile('/etc/svn/accessfile'); EOF
4. 修正 WebSVN 的 Bug (可能是吧 ^^)
WebSVN 在列出版序記錄時, 有時候會出現以下錯誤:
PHP Fatal error: Allowed memory size of xxxxx bytes exhausted (tried to allocate xxxxx bytes) in /var/www/html/websvn/include/svnlook.php on line 460
筆者本來以為是 php 的 memory_limit 太小所致, 後來即使把 memory_limit 調整到 512M, 1024M, 甚至 2048M, 上述錯誤還是時常會發生 (表示筆者的專案很認真的頻繁修改, 導致版序過多? ^^), 目前又沒時間去研究 root cause, 於是就偷懶一下, 修改 WebSVN 的 svnlook.php, 以避開上述問題.
# # # cd /var/www/html/websvn/include cp svnlook.php svnlook.php.`date +"%Y%m%d%H%M%S"` sed -i 's/\$curLog->path = str_replace/\/\/\$curLog->path = str_replace/g' svnlook.php