1,svn安裝
通過yum命令進行安裝,命令如下:
[root@localhost ~]$ yum -y install subversion
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.dgut.edu.cn
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
正在解決依賴關系
--> 正在檢查事務
---> 軟件包
subversion.x86_64.0.1.7.14-16.el7 將被 安裝
--> 正在處理依賴關系 subversion-libs(x86-64) = 1.7.14-16.el7,它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_wc-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_subr-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_repos-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_ra_svn-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_ra_neon-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_ra_local-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_ra-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_fs_util-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_fs_fs-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_fs_base-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_fs-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_diff-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_delta-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libsvn_client-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libaprutil-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在處理依賴關系 libapr-1.so.0()(64bit),它被軟件包
subversion-1.7.14-16.el7.x86_64 需要
--> 正在檢查事務
---> 軟件包 apr.x86_64.0.1.4.8-7.el7 將被 安裝
---> 軟件包
apr-util.x86_64.0.1.5.2-6.el7 將被 安裝
---> 軟件包
subversion-libs.x86_64.0.1.7.14-16.el7 將被 安裝
--> 解決依賴關系完成依賴關系解決
=========================================================================================================================================================================
Package 架構 版本 源 大小
=========================================================================================================================================================================
正在安裝:
subversion x86_64 1.7.14-16.el7 base 1.0 M
為依賴而安裝:
apr x86_64 1.4.8-7.el7 base 104 k
apr-util x86_64 1.5.2-6.el7 base 92 k
subversion-libs x86_64 1.7.14-16.el7 base 922 k事務概要
=========================================================================================================================================================================
安裝 1 軟件包 (+3 依賴軟件包)總下載量:2.1 M
安裝大小:7.5 M
Downloading packages:
(1/4):
apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:02
(2/4):
apr-1.4.8-7.el7.x86_64.rpm | 104 kB 00:00:03
(3/4):
subversion-1.7.14-16.el7.x86_64.rpm | 1.0 MB 00:00:09
(4/4):
subversion-libs-1.7.14-16.el7.x86_64.rpm | 922 kB 00:00:22
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
總計 96 kB/s | 2.1 MB 00:00:22
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : apr-1.4.8-7.el7.x86_64 1/4
正在安裝 :
apr-util-1.5.2-6.el7.x86_64 2/4
正在安裝 :
subversion-libs-1.7.14-16.el7.x86_64 3/4
正在安裝 :
subversion-1.7.14-16.el7.x86_64 4/4
驗證中 :
subversion-libs-1.7.14-16.el7.x86_64 1/4
驗證中 : apr-1.4.8-7.el7.x86_64 2/4
驗證中 :
subversion-1.7.14-16.el7.x86_64 3/4
驗證中 :
apr-util-1.5.2-6.el7.x86_64 4/4已安裝:
subversion.x86_64 0:1.7.14-16.el7作為依賴被安裝:
apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7 subversion-libs.x86_64 0:1.7.14-16.el7完畢!
2,創建svn版本庫
1)創建倉庫文件夾,命令如下:
[root@localhost opt]# mkdir -p /opt/svn/repository
2)創建svn版本庫,命令如下:
[root@localhost opt]# svnadmin create /opt/svn/repository
創建成功,進入/opt/svn/repository文件夾,信息如下:
[root@localhost opt]# cd /opt/svn/repository/
[root@localhost repository]# ll
總用量 8
drwxr-xr-x. 2 root root 54 6月 6 17:52 conf
drwxr-sr-x. 6 root root 233 6月 6 17:52 db
-r--r--r--. 1 root root 2 6月 6 17:52 format
drwxr-xr-x. 2 root root 231 6月 6 17:52 hooks
drwxr-xr-x. 2 root root 41 6月 6 17:52 locks
-rw-r--r--. 1 root root 229 6月 6 17:52 README.txt
3,權限配置
進入/opt/svn/repository/conf目錄,有如下三個文件:
[root@localhost conf]# ll
總用量 12
-rw-r--r--. 1 root root 1080 6月 6 17:52 authz
-rw-r--r--. 1 root root 309 6月 6 17:52 passwd
-rw-r--r--. 1 root root 3090 6月 6 17:52 svnserve.conf
文件說明:
authz:負責賬號權限的管理,控制賬號是否讀寫權限
passwd:負責賬號和密碼的用戶名單管理
svnserve.conf:svn服務器配置文件
1)authz配置
執行vim 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
admin=admin
dev=zhangsan,lisi,wangwu
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
#[/]表示根目錄,即/opt/svn/repository/
[/]
#@加組名稱,給該組賦權,r表示讀,w表示寫
@admin=rw
#[/dev]實際上為/opt/svn/repository/dev
[/dev]
@dev=rw
2)配置passwd
執行 vim passwd,配置svn訪問用戶和密碼:
### 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
# 等號前面為用戶名,后面為登錄密碼
admin = admin@123
zhangsan = zhang@123
lisi = li@123
wangwu = wang@123
3)配置 svnserve.conf
執行vim svnserve.conf,配置訪問權限,關鍵信息如下:
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = none
auth-access = write
### users have read and write access to the repository.
anon-access = none
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 = /opt/svn/repository
配置說明:
anon-access = none:表示禁止匿名用戶訪問
auth-access = write:表示授權用戶擁有讀寫權限
password-db = passswd:指定用戶名口令文件,即passwd文件
authz-db = authz:指定權限配置文件,即authz文件
realm = /opt/svn/repository:指定認證域,即/opt/svn/repository目錄
4,啟動svn服務
svn默認端口為3690,可以指定端口啟動,如3696,啟動命令如下:
[root@localhost ~]# svnserve -d -r /opt/svn --listen-port 3696
啟動成功后,通過ps -ef | grep svn查看進程,顯示如下信息:
[root@localhost ~]# ps -ef|grep svn
root 12499 1 0 22:04 ? 00:00:00 svnserve -d -r /opt/svn --listen-port 3696
root 13482 1386 0 22:05 pts/1 00:00:00 grep --color=auto svn
5,客戶端訪問svn服務器
使用IntelliJ IDEA編輯器,通過check out 拉取文件,如圖:
?編輯
?編輯
?編輯
提交文件至svn服務器,如圖:
?編輯 在此,svn服務器搭建完成,如果有問題,歡迎各位指正。
注意事項:1,上述操作都是采用root權限進行
2,需要關閉防火墻或者在防火墻配置中開放svn端口