linux下搭建svn代碼庫


1、安裝svn客戶端

2、創建svn代碼庫


1、安裝svn客戶端

  1.1、使用命令安裝

  1)CentOS

$ yum install subversion

  2)ubuntu

sudo apt-get install subversion

  1.2、源碼安裝

  http://www.cnblogs.com/fengbohello/p/4142810.html


 

2、開啟svn服務進程

  2.1、我的習慣是把代碼倉庫放在/opt/svn目錄下,所以先創建目錄/opt/svn

$ mkdir /opt/svn -p

  2.2、開啟svn服務進程

svnserve -d -r /opt/svn/

  這個命令的作用是開啟svn服務進程,並且把/opt/svn/目錄作為我們的svn服務的根目錄。以后,當我們要在客戶端checkout代碼的時候,svn服務進程就會從這里開始進行查詢,類似於apache的/var/www/目錄的作用。

  運行如下命令檢查svn服務是否開啟了。

# ps -ef | grep svn
root      2572     1  0 09:22 ?        00:00:00 svnserve -d -r /opt/svn/

  如果,出現以上結果,這說明svn服務正常開啟了。

  2.3、創建我們的第一個代碼倉庫:firsttest

# cd /opt/svn/ # svnadmin create firsttest

  這就創建了我們的第一個代碼倉庫,這個代碼倉庫的名字就叫做“firsttest”,可以看到其中的文件

# ls firsttest/
README.txt  conf  db  format  hooks  locks

  2.4、下面對我們的代碼倉庫進行權限設置

  1)進入conf目錄

# cd firsttest/conf/

  2)編輯svnserve.conf。這個文件是要告訴svn服務進程,我們的firsttest項目的認證權限和認證需要的密碼文件以及認證文件的存放位置。

  在第8行左右找到“[general]”,對其下面的內容進行編輯

# vim svnserve.conf
### Visit http://subversion.tigris.org/ for more information.
 [general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",

  其中需要編輯的地方分別是

  2.1)

### and "none".  The sample settings below are the defaults.
# anon-access = read
# auth-access = write
### The password-db option controls the location of the password

  修改為

### and "none".  The sample settings below are the defaults.
anon-access = none
auth-access = write
### The password-db option controls the location of the password

  注意,紅色的兩行前面不能有空格,否個svn會讀取失敗,下面的修改也要注意這些。

  2.2)

### Uncomment the line below to use the default password file.
# password-db = passwd
### The authz-db option controls the location of the authorization

  改為

### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization

  2.3)

### Uncomment the line below to use the default authorization file.
# authz-db = authz
### This option specifies the authentication realm of the repository.

  修改為

### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.

  對於一般的情況,修改到這里就可以了,下面的選項是加密選項等的加強版,這里就不說了。

  3)下面修改passwd文件。

# vim passwd

  3.1)找到“[users]”,在此選項下添加用戶“woshihehe”,“woshihehe”用戶對應的密碼是“123456”

[users]
# harry = harryssecret
# sally = sallyssecret
woshihehe = 123456

  4)修改authz文件

# vim authz

  在最后添加兩行

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]
woshihehe=rw

  這兩行的意思是,目錄[/](代碼根目錄)下的所有文件,如果沒有特殊約定的話,woshihehe用戶將具有讀(r)和寫(w)的權限。

3、下載代碼

  假如我的svn服務器的IP是192.168.1.105,在其它的機器上,執行如下代碼

# svn co svn://192.168.1.105:/firsttest --username woshihehe
認證領域: <svn://192.168.1.105:3690> My First Repository
“woshihehe”的密碼: 

  那么接下來輸入密碼就可以了

-----------------------------------------------------------------------
注意!  你的密碼,對於認證域:

   <svn://192.168.1.105:3690> My First Repository

只能明文保存在磁盤上!  如果可能的話,請考慮配置你的系統,讓 Subversion
可以保存加密后的密碼。請參閱文檔以獲得詳細信息。

你可以通過在“/root/.subversion/servers”中設置選項“store-plaintext-passwords”為“yes”或“no”,
來避免再次出現此警告。
-----------------------------------------------------------------------
保存未加密的密碼(yes/no)?yes
取出版本 0

  填寫yes,這樣我們就取出了我們的代碼,版本是0。這時候就可以在里面添加目錄和文件了。不過這個是如何使用svn了,這里就細說了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM