CentOS 7下搭建配置SVN服務器

CentOS 7下搭建配置SVN服務器

1. 安裝

CentOS經過yum安裝subversion。linux

$ sudo yum install subversion

 subversion安裝在/bin目錄:spring

$ which svnserve
/bin/svnserve

檢查一下subversion是否安裝成功。apache

$ svnserve --version
svnserve, version 1.7.14 (r1542130)
  compiled Nov 20 2015, 19:25:09

Copyright (C) 2013 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/

The following repository back-end (FS) modules are available:

* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.

Cyrus SASL authentication is available.服務器

2. 創建版本庫

subversion默認以/var/svn做爲數據根目錄,能夠經過/etc/sysconfig/svnserve修改這個默認位置。ssh

$ systemctl cat svnserve.service
# /usr/lib/systemd/system/svnserve.service
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/svnserve
ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS

[Install]
WantedBy=multi-user.target

$ cat /etc/sysconfig/svnserve
# OPTIONS is used to pass command-line arguments to svnserve.

# Specify the repository location in -r parameter:
OPTIONS="-r /var/svn"tcp

咱們修改/etc/sysconfig/svnserver將默認目錄指定到/opt/svn。svn

$ cat /etc/sysconfig/svnserve
OPTIONS="-r /opt/svn"

使用svnadmin創建版本庫spring-hello-world。測試

$ sudo mkdir -p /opt/svn
$ sudo svnadmin create /opt/svn/spring-hello-world

$ ll /opt/svn/
drwxr-xr-x. 6 root root 80 Nov 10 14:42 spring-hello-world

$ ll /opt/svn/spring-hello-world/
drwxr-xr-x. 2 root root  51 Nov 10 14:42 conf
drwxr-sr-x. 6 root root 4096 Nov 10 14:42 db
-r--r--r--. 1 root root    2 Nov 10 14:42 format
drwxr-xr-x. 2 root root 4096 Nov 10 14:42 hooks
drwxr-xr-x. 2 root root  39 Nov 10 14:42 locks
-rw-r--r--. 1 root root  229 Nov 10 14:42 README.txtspa

3. 配置

編輯用戶文件passwd,新增兩個用戶:admin和guest。版本控制

$ cat /opt/svn/spring-hello-world/conf/passwd 
[users]
admin = admin
guest = guest

編輯權限文件authz,用戶admin設置可讀寫權限,guest設置只讀權限。

$ cat /opt/svn/spring-hello-world/conf/authz 
[/]
admin = rw
guest = r

編輯svnserve.conf:

$ cat /opt/svn/spring-hello-world/conf/svnserve.conf 
[general]
anon-access = none                     #控制非鑑權用戶訪問版本庫的權限
auth-access = write                    #控制鑑權用戶訪問版本庫的權限
password-db = passwd                   #指定用戶名口令文件名
authz-db = authz                       #指定權限配置文件名
realm = spring-hello-world             #指定版本庫的認證域,即在登陸時提示的認證域名稱

 4. SVN服務

啓動SVN服務。

$ sudo systemctl start svnserve.service

檢查服務是否啓動成功。

$ ps aux | grep svn
root      16349  0.0  0.1 162180   900 ?        Ss   15:01   0:00 /usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid -r /opt/svn

經過netstat能夠看到SVN打開了3690端口。

$ sudo netstat -tnlp
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN      16349/svnserve

設置成開機啓動。

$ sudo systemctl enable svnserve.service

 5. 客戶端測試

客戶端能夠經過TortoriseSVN測試。

這時候可能會防火牆問題。若是是防火牆問題,會提示沒法鏈接。

客戶端用telnet沒法鏈接。

C:\Temp>telnet 192.168.12.59 360

用systemctl檢查服務器的防火牆配置:

$ firewall-cmd --list-all
public (default, active)
  interfaces: eno16777736 eno33554984
  sources: 
  services: dhcpv6-client ssh
  ports: 
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules:

能夠看到,沒有telnet服務和3690端口。增長telnet服務器和3690端口:

$ sudo firewall-cmd --permanent --add-service=telnet
$ sudo firewall-cmd --permanent --add-port=3690/tcp
$ sudo firewall-cmd --reload

客戶端再用telnet,應該就能夠了。

Ubuntu 14.04 下搭建SVN服務器 SVN://  http://www.linuxidc.com/Linux/2015-01/111956.htm

CentOS 7下安裝iF.svnadmin實現Web方式管理SVN(源碼安裝)  http://www.linuxidc.com/Linux/2016-08/134214.htm

CentOS7.2 編譯安裝SVN1.9.5客戶端  http://www.linuxidc.com/Linux/2017-03/141387.htm

SVN 服務器搭建步驟及使用實戰 http://www.linuxidc.com/Linux/2017-01/139282.htm

Windows下SVN服務器搭建和使用 + 客戶端從新設置密碼 http://www.linuxidc.com/Linux/2013-05/85189p5.htm

CentOS 6.6搭建SVN服務器 http://www.linuxidc.com/Linux/2016-12/137864.htm

CentOS 7.2下Nginx+MySQL+PHP-FPM+SVN配置Walle自動化部署系統詳解 http://www.linuxidc.com/Linux/2016-11/137703.htm

基於騰訊CentOS 7雲服務器搭建SVN版本控制庫  http://www.linuxidc.com/Linux/2017-05/144244.htm

CentOS 7.1 下SVN安裝與配置 http://www.linuxidc.com/Linux/2016-12/138637.htm

CentOS 6.8 搭建SVN(版本控制系統)及SVN的使用  http://www.linuxidc.com/Linux/2017-04/143093.htm

Subversion (SVN) 的詳細介紹請點這裏
Subversion (SVN) 的下載地址請點這裏

本文永久更新連接地址http://www.linuxidc.com/Linux/2017-05/144254.htm

相關文章
相關標籤/搜索