一、SVN架構圖

二、SVN服務器部署(三種方案)

配置第一種服務:Apache + mod_dav_svn
第一步: 准備工作:
CentOS 6.8 Server Linux 系統基礎配置工作
第二步:安裝httpd 與 svn
yum install -y httpd
yum install -y subversion mod_dav_svn
確認Apache已經安裝mod_dav_svn, 與 authz_svn 模塊
# ls /etc/httpd/modules/ | grep svn mod_authz_svn.so mod_dav_svn.so
第三步:建立SVN根目錄
mkdir -p /var/www/svn svnadmin create /var/www/svn/project vim /var/www/svn/project/conf/svnserve.conf anon-access = none auth-access = write
chown apache:apache -R /var/www/svn/
第四步:SVN 整合apache,配置/etc/httpd/conf.d/subversion.conf文件
<Location /project> DAV svn SVNPath /var/www/svn/project SVNAutoversioning on AuthType Basic AuthName "SVN Authorization Realm" AuthUserFile /var/www/svn/project/conf/passwd Require valid-user </Location>
第五步:創建SVN用戶
cd /var/www/svn/project/conf #使用htpasswd創建用戶,首次創建用戶 htpasswd -cb passwd user password #添加用戶 htpasswd -b passwd new-user new-password #刪除用戶 htpasswd -D passwd user #修改用戶密碼 htpasswd passwd user
第六步:配置SVN權限,編輯authz文件
vi /var/www/svn/project/conf/authz
[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
guest = test,abc,user
[/]
guest = rw
* = r
#設置根目錄下guest組為可讀寫,其他用戶可讀
# [/foo/bar]
# harry = rw
第七步:啟動SVN服務
svnserve -d -r /var/www/svn/project
查看服務
[root@localhost conf]# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1020/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1100/master tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1396/svnserve tcp 0 0 :::22 :::* LISTEN 1020/sshd tcp 0 0 ::1:25 :::* LISTEN 1100/master
SVN端口號為3690
第八步:使用瀏覽器確認

使用客戶端確認

三、SVN使用
# svn help usage: svn <subcommand> [options] [args] Subversion command-line client, version 1.6.11. Type 'svn help <subcommand>' for help on a specific subcommand. Type 'svn --version' to see the program version and RA modules or 'svn --version --quiet' to see just the version number. Most subcommands take file and/or directory arguments, recursing on the directories. If no arguments are supplied to such a command, it recurses on the current directory (inclusive) by default. Available subcommands: add blame (praise, annotate, ann) cat changelist (cl) checkout (co) cleanup commit (ci) copy (cp) delete (del, remove, rm) diff (di) export help (?, h) import info list (ls) lock log merge mergeinfo mkdir move (mv, rename, ren) propdel (pdel, pd) propedit (pedit, pe) propget (pget, pg) proplist (plist, pl) propset (pset, ps) resolve resolved revert status (stat, st) switch (sw) unlock update (up) Subversion is a tool for version control. For additional information, see http://subversion.tigris.org/
使用功能 1. 導入數據到你的版本庫 (svn import && svn add)
SVN 推薦版本布局
$ svn list file:///var/svn/single-project-repo trunk/ branches/ tags/
$ svn list file:///var/svn/multi-project-repo project-A/ project-B/
$ svn list file:///var/svn/multi-project-repo/project-A trunk/ branches/ tags/ $
svn import /path/to/you/want/to/upload \ http://192.168.112.193/project \ -m "Initial Import"
svn list http://192.168.112.193/project
使用功能2. 創建工作副本 (svn checkout http://192.168.112.193/project)
