基本的安裝包有: subversion /httpd/ svn的httpd的mod_dav_svn mod_authz_svn 兩個模組.(yum install mod_dav_svn subversion httpd )
svn的服務形式應該是有兩種: 1 通過svnserve建立的 通過svn://ip:port 連接埠預設是3690,這種形式; 2 通過apache httpd或者其他的web伺服器的擴充模組,進行svn管理
對於svnserve,通過svnserve -d -r /var/www/svn 這種形式建立 daemon的後台進程,但是結束要 kill `pgrep svnserve` 這種形式 來kill掉,不知道有沒有直接的比如 stop的方式.
通過http伺服器來管理svn也很不錯,可以很方便的瀏覽.其配置過程如下(首先幾個軟體都安裝,這就不用說了.):
1.在 /etc/httpd/module下面 有兩個 mod 關於 svn的.
2.在/etc/httpd/config.d/下有一個subversion.conf(沒有就建立一個),其內容是:
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
<Location /svn>
DAV svn
SVNPath /var/www/svn/
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /var/www/svn/repos1/conf/passwd
Require valid-user
</Location>
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
# # cd /var/www/svn
# # svnadmin create stuff
# # chown -R apache.apache stuff
# # chcon -R -t httpd_sys_content_t stuff
#<Location /repos>
# DAV svn
# SVNParentPath /var/www/svn
#
# # Limit write permission to list of valid users.
# <LimitExcept GET PROPFIND OPTIONS REPORT>
# # Require SSL connection for password protection.
# # SSLRequireSSL
#
# AuthType Basic
# AuthName "Authorization Realm"
# AuthUserFile /path/to/passwdfile
# Require valid-user
# </LimitExcept>
#</Location>
其中/var/www/svn是準備放倉庫的目錄,這個目錄可以放置多個代碼倉庫,AuthUserFile就是使用者和密碼的檔案,也可以移動到其他地方單獨管理.
/var/www/svn 下面可以通過 svnadmin createa /var/www/svn/repos1 來建立一個空的倉庫.還可以建立多個倉庫;這個目錄貌似最好 給apche使用者所有許可權:chown -R apache.apache /var/www/svn ;在repos1/conf目錄下可以進行一些帳號密碼 配置,就不多說了.建立的其他倉庫 可以拷貝這些conf檔案
其中AuthUserFile 是如何製作的呢?
建立“ AuthUserFile ”設定所需的使用者密碼以及儲存的檔案使用 apache bin/htpasswd 命令來建立。命令的格式為htpasswd [-cmdpsD] passwordfile username若第一次建立使用者,我們必須使用參數“-c”來同時建立使用者密碼檔案htpasswd -c passwd robert上述命令建立的一個檔案“ passwd”,同時在檔案裡添加了一個 user named “robert”,執行該命令時會要求輸入密碼。注意:建立第二或之後的使用者時,一定不能用參數“ c ”,否則之前的使用者就會被刪除。如果想要刪除某個使用者,我們可以使用下列命令: htpasswd -D passwd robert這樣, robert就被從 passwd中刪除了。
下面就是一個樣本,建立兩個使用者 a b,密碼 aaa,bbb,再刪除。查看密碼檔案內容:
[root@src-server websvn]# htpasswd accesspwd ahtpasswd: cannot modify file accesspwd; use '-c' to create it[root@src-server websvn]# htpasswd -c accesspwd aNew password:Re-type new password:Adding password for user a[root@src-server websvn]# ll accesspwd-rw-r--r-- 1 root root 16 Jun 23 02:03 accesspwd[root@src-server websvn]# htpasswd accesspwd bNew password:Re-type new password:Adding password for user b[root@src-server websvn]# cat accesspwda:wpEqdKjINQsvMb:JEpHUbhZZP3fc[root@src-server websvn]# htpasswd -D accesspwd bDeleting password for user b[root@src-server websvn]# cat accesspwda:wpEqdKjINQsvM[root@src-server websvn]#
3. sudo service httpd restart 重啟httpd apache 服務. 貌似很簡單呢..回來再整理下svn的命令 補充.
然後通過 http://IP/svn/repos1可以訪問這個倉庫,可以建立多個倉庫同時訪問.不過直接存取 IP/svn 無法列出倉庫的列表,apache顯示 "forbidden \n You don't have permission to access /svn on this server"
對於一些svn的web管理程式也有,比如ViewVC 還有一些其他的管理svn的web程式,最好可以在web端建立倉庫、許可權管理就好了。目前尋找這樣的svn web管理程式中。
CentOS 安裝websvn直接yum即可,不需要配置mysql,只需要php的支援即可。
查看websvn的包檔案
[root@src-server ~]# yum install websvnLoaded plugins: fastestmirror, presto, refresh-packagekitLoading mirror speeds from cached hostfile * base: mirrors.btte.net * epel: ftp.kddilabs.jp * extras: ftp.stu.edu.tw * kernel-xen: us1.mirror.crc.id.au * updates: mirrors.tuna.tsinghua.edu.cnSetting up Install ProcessPackage websvn-2.3.3-2.el6.noarch already installed and latest versionNothing to do[root@src-server ~]#rpm -ql websvn/etc/httpd/conf.d/websvn.conf/etc/websvn/config.php/usr/share/doc/websvn-2.3.3/usr/share/doc/websvn-2.3.3/changes.txt/usr/share/doc/websvn-2.3.3/doc/usr/share/doc/websvn-2.3.3/doc/install.html/usr/share/doc/websvn-2.3.3/doc/style.css/usr/share/doc/websvn-2.3.3/doc/templates.html/usr/share/doc/websvn-2.3.3/license.txt/usr/share/websvn/usr/share/websvn/blame.php/usr/share/websvn/cache/usr/share/websvn/comp.php/usr/share/websvn/diff.php/usr/share/websvn/dl.php/usr/share/websvn/filedetails.php/usr/share/websvn/include/usr/share/websvn/include/accessfile.php/usr/share/websvn/include/auth.php/usr/share/websvn/include/bugtraq.php/usr/share/websvn/include/command.php/usr/share/websvn/include/config.php/usr/share/websvn/include/configclass.php/usr/share/websvn/include/diff_inc.php/usr/share/websvn/include/diff_util.php/usr/share/websvn/include/header/usr/share/websvn/include/setup.php/usr/share/websvn/include/svnlook.php/usr/share/websvn/include/template.php/usr/share/websvn/include/utils.php/usr/share/websvn/include/version.php/usr/share/websvn/index.php/usr/share/websvn/languages/usr/share/websvn/languages/chinese-simplified.php/usr/share/websvn/languages/languages.php/usr/share/websvn/languages/省略省略省略/usr/share/websvn/listing.php/usr/share/websvn/log.php/usr/share/websvn/revision.php/usr/share/websvn/rss.php/usr/share/websvn/temp/usr/share/websvn/templates/usr/share/websvn/templates/BlueGrey/usr/share/websvn/templates/BlueGrey/省略省略省略/usr/share/websvn/templates/Elegant/usr/share/websvn/templates/Elegant/省略省略省略/usr/share/websvn/templates/calm/usr/share/websvn/templates/calm/省略省略省略/usr/share/websvn/wsvn.php/var/cache/websvn
下面就是vim /etc/websvn/config.php,其實這個檔案就是/usr/share/websvn/include/config.php,只是做了一個連結到etc目錄,這種方法對於這種需要配置的web程式來說,還真是方便。
[root@src-server ~]# ll /etc/websvn/config.php-rw-r--r-- 1 root root 21210 Jun 24 18:48 /etc/websvn/config.php[root@src-server ~]# ll /usr/share/websvn/include/config.phplrwxrwxrwx 1 root root 33 Jun 23 01:01 /usr/share/websvn/include/config.php -> ../../../../etc/websvn/config.php[root@src-server ~]#
這裡需要修改的配置選項有:
$config->parentPath('/srv/svn/');
$config->useMultiViews();
############ $config->useAuthenticationFile('/srv/svn/passwd');#這裡是因為我 不知道如何在websvn上登入我的帳號
$config->setBlockRobots();#防止搜尋程式收錄
$config->expandTabsBy(4);#預設的8 似乎並不適合我的習慣
$config->useEnscript();##文法高亮 建議安裝GNU Enscript高亮顯示程式包,官方下載:http://www.iki.fi/~mtr/genscript/
# 關於編碼 我不知道如何設定,SetInputEncoding 對於我的websvn-2.3.3不起作用,反而websvn出現500錯誤。
修改/etc/httpd/conf.d/websvn.conf 添加基本許可權認證
Alias /websvn /usr/share/websvn/<Directory /usr/share/websvn/> Options MultiViews Indexes DirectoryIndex wsvn.php order allow,deny allow from all AuthType Basic AuthName "Authorization Realm" AuthUserFile /srv/svn/passwd Require valid-user</Directory>
websvn就可以線上瀏覽了。
第三節:線上修改htpasswd密碼
前面是由apache的htpasswd來通過 base 認證來進行帳號管理的。通過這個小程式可以線上添加刪除 校正帳號密碼。還有點小遺憾是 沒有對 添加 刪除 進行許可權管理。校正後 才可以進行這個選項。
http://www.cnblogs.com/mutuan/archive/2012/07/27/2611537.html
參考:http://www.scmbbs.com/cn/svntp/2007/11/svntp1.php