Linux下Subversion(SVN服務器)的搭建:
1、安裝Subversion
#查看本機是否已安裝subversion
[root@test2 etc]# rpm -qa subversion
[root@test2 etc]#
#卸載舊版
[root@test2 etc]# yum remove subversion
#安裝SVN 為了便於以后操作同時安裝其他服務 可以僅安裝SVN
[root@test2 etc]# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql
確認已安裝了svn模塊
驗證安裝:
[root@test2 conf]# svnserve --version
svnserve,版本 1.6.11 (r934486)
編譯於 Apr 11 2013,16:13:51
版權所有 (C) 2000-2009 CollabNet。
Subversion 是開放源代碼軟件,請參閱 http://subversion.tigris.org/ 站點。
此產品包含由 CollabNet(http://www.Collab.Net/) 開發的軟件。
下列版本庫后端(FS) 模塊可用:
* fs_base : 模塊只能操作BDB版本庫。
* fs_fs : 模塊與文本文件(FSFS)版本庫一起工作。
Cyrus SASL 認證可用。
2、創建代碼庫
[root@test2 etc]# mkdir -p /opt/svn/repositories
[root@test2 etc]# svnadmin create /opt/svn/repositories
執行上面的命令后,自動建立repositories庫,查看/opt/svn/repositories
文件夾發現包含了conf, db,format,hooks, locks, README.txt等文件,說明一個SVN庫已經建立。
subversion目錄說明:
*db目錄:就是所有版本控制的數據存放文件
*hooks目錄:放置hook腳本文件的目錄
*locks目錄:用來放置subversion見艱苦鎖定數據的目錄,用來追蹤存取文件庫的客戶端
*format文件:是一個文本文件,里面只放了一個整數。表示當前文件庫配置的版本號
*conf目錄:是這個倉庫的配置文件(倉庫的用戶訪問賬號、權限等)
3、添加用戶
要添加SVN用戶非常簡單,只需在/opt/svn/repositories/conf/passwd文件添加一個形如“username=password”的條目就可以了。為了測試,我添加了如下內容:
[users]
# harry = harryssecret
# sally = sallyssecret
pm = pm_pw
server_group = server_pw
client_group = client_pw
test_group = test_pw
4、用戶權限控制
在/opt/svn/repositories/conf/authz文件
[groups]
在這里創建權限組並指定組內用戶,中間用,分割
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = zhangcy,liuzz,shenkun
user = yangxt,maym,lizh,dongyan
為權限組分配權限
[/]
@admin = rw
@user = rw
* =
r表示對該目錄有讀權限,w表示對該目錄有寫權限,rw表示對該目錄有讀寫權限。
最后一行的* =表示,除了上面設置了權限的用戶組之外,其他任何人都被禁止訪問本目錄。這個很重要,一定要加上!
5、修改svnserve.conf文件,讓用戶和策略配置升效.
[general]
anon-access = none
auth-access = write
password-db = /opt/svn/repositories/conf/passwd
authz-db =/opt/svn/repositories/conf/authz
6、啟動svn服務器
svnserve -d -r /opt/svn/repositories/ 或者指定端口號啟動服務器 svnserve -d -r /opt/svn/repos --listen-port 3391
svn默認監聽3690端口
參考資料如下
http://jingyan.baidu.com/article/d45ad148e9cfc069542b8046.html
7、MyEclipse中SVN插件的安裝
到這里下載MyEclipse下SVN插件(zip包): http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240
在MyEclipse安裝目錄dropins下新建SVN文件夾,並將下載后的zip包解壓后的features 和 plugins 文件夾移動到SVN下,之后重啟MyEclipse。
重啟后在MyEclipse 》Window 》Show View 》other中找到SVN,並顯示SVN資源庫並在資源庫中鏈接服務器。
參考資料: http://www.cnblogs.com/xdp-gacl/p/3497016.html
8、為SVN新建項目
在MyEclipse下新建或選擇要用SVN進行版本控制的項目,右鍵項目選擇Team下的Share Project,按照提示即可將項目交由SVN進行版本控制。
9、MyEclipse中SVN插件的使用: http://blog.sina.com.cn/s/blog_8a3d83320100zhmp.html