linux 搭建svn,linuxsvn

來源:互聯網
上載者:User

linux 搭建svn,linuxsvn

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 svnroot      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 = noneauth-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 = sallyssecretwoshihehe = 123456

  4)修改authz檔案

# vim authz

  在最後添加兩行

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

如果是所有人都可以checkout,那麼就要修改成* = 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了,這裡就細說了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.