Linux伺服器SVN配置及管理專案遷移
前言:本文章根據有些公司對於專案管理,所以有些公司對於SVN使用有些挑剔,有些會使用GIT或者Github等等,這不我們公司使用的就是SVN,技術老大說要把Windows系統上的SVN專案遷移至公司Linux伺服器上,順便在Linux上面搭建SVN及配置SVN,小編在這裡一萬句mmp,第一次還要遷移至Linux伺服器上,沒辦法搞唄,然後去網上查了一下,大部分的教程都是一樣,沒啥新意,但是有很多講的教程資訊不全,看到這裡就想罵那些人,給人留這麼多坑。經過我一天的研究,完美成功,下面就請大家來欣賞。
安裝 SVN:
yum install subversion
建立svn倉庫路徑:
# cd /opt/svn/ # svnadmin create/opt/svn/test
drwxr-xr-x 2 root root 4096 Mar 30 20:05 conf drwxr-sr-x 6 root root 4096 Mar 30 20:05 db -r--r--r-- 1 root root 2 Mar 30 20:05 format drwxr-xr-x 2 root root 4096 Mar 30 20:05 hooks drwxr-xr-x 2 root root 4096 Mar 30 20:05 locks -rw-r--r-- 1 root root 229 Mar 30 20:05 README.txt
配置檔案講解:
上面的檔案中 , 資料夾 conf 是用來存放配置檔案的 :
authz 是許可權控制檔案
passwd 是帳號密碼檔案
svnserve.conf 是SVN服務配置檔案
配置 authz:
### This file is an example authorization file for svnserve. ### Its format is identical to that of mod_authz_svn authorization ### files. ### As shown below each section defines authorizations forthe path and ### (optional) repository specified by the section name. ### The authorizations follow. An authorization line can refer to: ### - a single user, ### - a group of users defined in a special [groups] section, ### - an alias defined in a special [aliases] section, ### - all authenticated users, using the '$authenticated' token, ### - only anonymous users, using the '$anonymous' token, ### - anyone, using the '*' wildcard. ### ### A match can be inverted by prefixing the rule with '~'. Rules can ### grant read ('r') access, read-write ('rw') access, or no access ### (''). [aliases] # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average [groups] # harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe #使用者組 dev = dev #專案使用者名稱 bbt = yukai.li,test # [/foo/bar] # harry = rw # &joe = r # * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r #給予使用者加入讀寫許可權 [/] @dev = rw [/] @bbt = rw
配置 passwd:
[[email protected]dev conf]# more passwd ### This file is an example password file for svnserve. ### Its format is similar to that of svnserve.conf. As shown in the ### example below it contains one section labelled [users]. ### The name and password for each user follow, one account per line. #使用者名稱及加入使用者名稱密碼 [users] # harry = harryssecret # sally = sallyssecret test = 123456 yukai.li = 666666
修改配置 svnserve.conf,這裡按照我配置修改就可以了:
#把這個幾個前面#去掉就可以了,最後一個直接填寫你建立的專案目錄名 anon-access = one auth-access = write password-db = passwd authz-db = authz realm = test
[[email protected]dev conf]# more svnserve.conf ### This file controls the configuration of the svnserve daemon, if you ### use it to allow access to this repository. (If you only allow ### access through http: and/or file: URLs, then this file is ### irrelevant.) ### 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", ### and "none". The sample settings below are the defaults. anon-access = one auth-access = write ### The password-db option controls the location of the password ### database file. Unless you specify a path starting with a /, ### the file's location is relative to the directory containing ### this configuration file. ### If SASL is enabled (see below), this file will NOT be used. ### Uncomment the line below to use the default password file. password-db = passwd ### The authz-db option controls the location of the authorization ### rules for path-based access control. Unless you specify a path ### starting with a /, the file's location is relative to the the ### directory containing this file. If you don't specify an ### authz-db, no path-based access control is done. ### Uncomment the line below to use the default authorization file. authz-db = authz ### This option specifies the authentication realm of the repository. ### If two repositories have the same authentication realm, they should ### have the same password database, and vice versa. The default realm ### is repository's uuid. realm = test [sasl] ### This option specifies whether you want to use the Cyrus SASL ### library for authentication. Default is false. ### This section will be ignored if svnserve is not built with Cyrus ### SASL support; to check, run 'svnserve --version' and look for a line ### reading 'Cyrus SASL authentication is available.' # use-sasl = true ### These options specify the desired strength of the security layer ### that you want SASL to provide. 0 means no encryption, 1 means ### integrity-checking only, values larger than 1 are correlated ### to the effective key length for encryption (e.g. 128 means 128-bit ### encryption). The values below are the defaults. # min-encryption = 0 # max-encryption = 256 [[email protected]-dev conf]#
啟動服務:
# svnserve -d -r /opt/svn/test
檢視SVN程序:
# ps -ef|grep svn root 12538 1 0 14:40 ? 00:00:00 svnserve -d -r /opt/svn/test #或者直接用這個命令檢視; [[email protected]-dev bbt]# ps -aux root 6122 0.0 0.0 152416 864 ? Ss Sep21 0:00 svnserve -d -r /opt/svn/test #這樣表示已啟動成功,再啟動的時候你只需要啟動你建立的beibeitou這個專案目錄就好;
客戶端連線:
使用 TortoiseSVN , 輸入地址svn://192.168.0.204:3690/即可 , 再輸入使用者名稱和密碼就能訪問了 (注:那個埠加不加都行了,我個人測試了一下可以不用新增,另外解釋一下為什麼地址開頭是svn,是因為 這個表示Linux伺服器上定義的一個區別,用來區分http表示Windows上的svn,小編個人是這麼認為的,如大家想知道,可以去研究一下)
停止重啟SVN:
# killall svnserve //停止 # svnserve -d -r /opt/svn/test // 啟動
匯入專案原始碼:
# svn import [源路徑][目標版本庫路徑] -m [日誌資訊]//例如: svn import /home/work/ file:///svn/project1/trunk/ -m "Initial import" #不過我這裡沒有這樣操作使用,可以看看繼續操作,因為感覺那樣來回操作很麻煩;
接下來是我個人匯入專案原始碼的方式,我是直接使用SVN客戶端方式匯入,我認為那樣比較安全,速度還是比較安全,你只需要把個人專案從SVN拉到本地電腦上,之後連線用客戶端連線我們建立好的svn伺服器,不多說了請大家看圖:
1、首先桌面隨便建立一個資料夾,選中右鍵然後選中版本庫瀏覽器,輸入地址
2、確定後,就會彈出讓你輸入使用者名稱和密碼,這裡小編認為最好不要儲存密碼
3、確定密碼後,就會彈出下面這個頁面;
4、我們剛搞好的SVN伺服器裡面,這個裡面是空的,所以你只需要選擇左邊的那個地址然後右鍵,直接新建立一個檔名,之後選中新建立的資料夾,然後右鍵選中加入資料夾,然後找到你拉下來的專案,然後確定就OK了,匯入完後,個人可以直接checkOut一下就知道了
linux搭建配置SVN,eclipse連線時遇到的問題
到這裡,小編還沒講完,因為搞好這些,我以為就完事了,因為我公司統一使用的eclipse開發,所以eclipse外掛還是個問題,我在直接新建立資源位置的時候發現直接會返回這個錯誤Eclipse中的Subversion版本控制工具出現Malformed network data的問題,然後小編當場就蒙了,第一次遇到這個問題,我便上網查了很久後,都不可以,最後小編髮現了一個牛掰的部落格,我試了一下果然OK了,下面我給大家分享出來。
Eclipse安裝SVN外掛
使用SVN進行專案的版本管理是非常流行的操作,這篇部落格將描述Eclipse安裝SVN的方法(Linux安裝伺服器端的請參考CentOS安裝SVN)。
從選單欄依次開啟 Help - Install New Software,然後在彈出的視窗點選Add,在Location裡面輸入如下地址,獲取最新的SVN外掛,如果需要其他版本,可以在 https://github.com/subclipse/subclipse/wiki 查詢。
Subclipse - https://dl.bintray.com/subclipse/releases/subclipse/latest/
Name可以隨便寫,可以寫Subversion,然後點選確定,等到獲取了所有的外掛列表後,勾選這些外掛,點選下一步,然後接受協議,一步一步安裝就好了。
安裝完成後,需要開啟SVN檢視,在選單欄依次點選 Window - Show View - Other,然後選擇 SVN - SVN資源庫,在資源庫空白處右鍵單擊,選擇新建 - 資源庫位置。然後依次填寫資訊即可。