1 先查看是否已經安裝了svnhtml
若是沒有安裝svn則:linux
ubuntu@ip-172-31-29-46:~$ svn --version The program 'svn' is currently not installed. You can install it by typing: sudo apt-get install subversion
若是已經安裝svn則提示svn版本號:apache
cfj@cfj-virtual-machine:~$ svn --version svn,版本 1.9.7 (r1800392) 編譯於 Mar 28 2018,08:49:13 在 x86_64-pc-linux-gnu Copyright (C) 2017 The Apache Software Foundation. This software consists of contributions made by many people; see the NOTICE file for more information. Subversion is open source software, see http://subversion.apache.org/
2 ubuntu安裝svn:ubuntu
先更新一下(可選)服務器
sudo apt-get update
svn
在線安裝命令:阿里雲
sudo apt-get install subversion
3 建立版本庫spa
在/opt/下面用mkdir命令建立目錄svn以及子目錄repository。目錄結構: /opt/svn/repository.net
更改更改repository文件夾的權限 改成7773d
sudo chmod -R 777 /opt/svn/repository
將剛剛建立的目錄利用svn命令指定爲版本庫:
sudo svnadmin create /opt/svn/repository
設置完成以後在repository下面會生產幾個文件夾和文件
主要的配置文件在conf文件夾下面:svnserve.conf,passwd,authz
4 修改repository文件夾下面的內容,完善配置
sudo chmod -R 777 /opt/svn/repository/db
ubuntu@ip-172-31-29-46:/opt/svn/repository$ cd conf ubuntu@ip-172-31-29-46:/opt/svn/repository/conf$ sudo vi svnserve.conf
#匿名用戶可讀
anon-access = read(可改爲none,即不可讀)
#權限用戶可寫
auth-access = write
#密碼文件爲passwd
password-db = passwd
#權限文件爲authz
authz-db = authz
(去掉前面的#,而且頂格,否則可能會報錯)
格式:用戶名=密碼(明文)
sudo vi passwd
以上設置用戶爲admin密碼爲admin
sudo vi authz
若是組內有多我的能夠逗號分隔如:組名owner,組員user1,user2則:owner=user1,user2
對組的訪問權限設置:rw,r,w。組名前面加@
@owner=rw
若是單用戶設置則一個用戶一行:
user1=rw
單庫模式則設置爲:[/] 本例子爲單庫模式
5 啓動svn版本庫
svnserve -d -r /opt/svn/repository
-d:表示在後臺運行 ,-r:指定服務器的根目錄
啓動以後能夠查看進程:
ubuntu@ip-172-31-29-46:/opt/svn/repository/conf$ ps -ef|grep svnserve ubuntu 12593 1 0 13:37 ? 00:00:00 svnserve -d -r /opt/svn/repository ubuntu 12595 11736 0 13:37 pts/0 00:00:00 grep --color=auto svnserve
若是須要中止,則kill -9 進程號
查看端口號,默認端口3690
sudo netstat -ntlp
6 訪問:經過svn://服務器ip/文件夾名字 從svn客戶端訪問服務器。默認svn協議。若是要配置http或者https則須要安裝apache。
本例由於是設置的[/],則svn://ip地址/
就能夠訪問
注意:若是是阿里雲或者亞馬遜的服務器,可能svn端口號沒有對外開通,須要在控制檯中配置。
參考:
https://blog.csdn.net/sm_wang/article/details/78656120http://www.runoob.com/svn/svn-start-mode.htmlhttps://blog.csdn.net/u011781521/article/details/54981945http://wiki.ubuntu.org.cn/SubVersion#.E7.9B.B4.E6.8E.A5.E8.AE.BF.E9.97.AE.E6.96.87.E4.BB.B6.E4.BB.93.E5.BA.93.28file:.2F.2F.29