SVN的安装

yum install subversion

服务端命令

1. svnserver - 控制svn系统服务的启动等

2. svnadmin - 版本库的创建/导出/导入/删除等

3. svnlook - 查看版本库的信息等

客户端命令

1. svn - 版本库的检出/更新/提交/重定向等

创建版本库

1. svnadmin create /www/version_test_1;

2. cd /www; svnadmin create version_test_2;

注意:如果 cd /www/version_test_1; svnadmin create version_test_2 会抛出异常(svnadmin: E165002: '/www/version_test_1/version_test_2' is a subdirectory of an existing repository rooted at '/www/version_test_1'),故不能再已有版本库里面再次创建版本库。

3. 指定版本库数据保存类型: svnadmin create --fs-type fsfs(数据保存类型,还可以指定dbd) xxxx(版本库名称),如果想了解fsfs和dbd的区别可以自行百度,这里不过多阐述;推荐使用fsfs数据保存类型;

删除版本库

1. rm -rvf /www/version_test_1;使用linux自带的命令把整个版本库删除即可;

版本库配置

配置文件位于: /www/version_test_2/conf/

存在三个文件分别是:

  1. authz -- 配置用户组以及用户组权限

  2. passwd -- 配置用户名和密码

  3. svnserve.conf -- 配置默认权限、权限配置文件及密码配置文件

版本库权限分组

vim 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.apache.org/ for more information. [general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# anon-access = read
# 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 [general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# anon-access = read
# 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 = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above. Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none [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. means no encryption, means
### integrity-checking only, values larger than are correlated
### to the effective key length for encryption (e.g. means -bit
### encryption). The values below are the defaults.
# min-encryption =
# max-encryption =

在19行: anon-access = read || write || none,表示没有用户名和密码的用户访问该版本库怎么操作

在20行: auth-access = write || read || none,表示通过用户名和密码的用户访问该版本库怎么操作

上述 read、write 、none 意思:

1. read 指允许更新代码

2. write 指允许更新代码,也允许提交代码

3. none 指什么都干不了

在27行: password-db = passwd,表示指定用户名和密码的文件路径(既支持相对路径,又支持绝对路径)

在58行: authz-db = authz,表示指定权限分组的文件路径(既支持相对路径,又支持绝对路径)

最终将svnserve.conf文件修改为:

anon-access = none

auth-access = write

password-db = passwd

authz-db = authz

:wq 保存退出即可。

vim 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

在7、8行已经给出了用户和密码的格式,则现只需要在9行添加:

jiangbo = 

随后再可以添加其他人来操作该版本库:

zhangsan = 
lisi = 
wangwu = 

:wq 保存退出即可。

vim 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 for the 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 # [/foo/bar]
# harry = rw
# &joe = r
# * = # [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

在18行:别名配置

在21行:用户组配置,格式是(组名 = 用户1,用户2,...,用户n)

示例:

[groups]
# 产品经理组
pm = jiangbo
# 开发人员组
dev = zhangsan,wangwu
# 菜鸟组
rookie = lisi

在25行:表示版本库的目录,例如 [/] 表示版本库的根目录,[/foo/bar] 表示版本库根目录下的 foo 文件夹下面的 bar 文件夹

示例:

[/]
# 表示项目径路组有更新和提交的权限
@pm = rw
# 表示开发组只有更新的权限
@dev = r
# 表示 李四 这个用户自由更新的权限
lisi = r

在30行:表示repository版本库下目录,例如 [repository:/] 表示repository版本库的根目录,[repository:/baz/fuz] 表示repository版本库目录下的 baz 文件夹下面的 fuz 文件夹

示例:

[version_test_n:/]
# 表示该版本库下面所有用户都有更新和提交的权限
* = rw

:wq 保存退出即可。

版本库的访问

服务端和客户端的关系(svn服务端 :svn客户端 = 1 : n )

运行svn服务端: svnserve -d -r /www/version_test_2/ ,如果没有什么异常消息则证明svn服务端运行成功!

个人定义的版本库的访问两种形式:

  1. 命令行的形式访问

    $ mkdir svntest

    $ cd svntest

    /svntest$ svn checkout(co) svn://192.168.0.104 (--username jiangbo --password 123456)

  2. 图像界面的形式访问

    下载tortoisesvn进行svn检出

SVN服务自启动

vim /etc/rc.local:

 #!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot. touch /var/lock/subsys/local

在13行下面加上 svn 服务自启动:

svnserve -d -r /www/version_test_2/

特别注意:

安装好 svn 服务后,默认是没有随系统启动自动启动的, CentOS 7 的 /etc/rc.d/rc.local 是没有执行权限的, 系统建议创建 systemd service 启动服务

于是查看 systemd 里 svn 的配置文件 /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

找到 svn 的 service 配置文件 /etc/sysconfig/svnserve 编辑配置文件

vi /etc/sysconfig/svnserve

将 OPTIONS="-r /var/svn" 改为 svn 版本库存放的目录,:wq 保存退出

然后在提示符下输入

systemctl enable svnserve.service  

重启服务器,输入

ps -aux | grep 'svn'  

看 svn 服务启动了没有。。。

****************************************************************************************************************

常见 SVN 客户端命令

###
### 基础操作
###
svn checkout(co) - 检出
# 检出一个版本库(/目录) (并且带有用户名和密码)
ex : svn co svn://127.0.0.1(/dir) (--username jiangbo --password 123456)
svn add - 添加到版本控制
# 添加一个index.php二进制文件到版本控制(并未提交到版本库)
ex : svn add index.php
# 添加一个pic.png树文件到版本控制(并未提交到版本库)
ex : svn add pic.png
# (递归)添加一个css目录及下面所有文件夹和文件到版本控制(并未提交到版本库)
ex : svn add css
# (未递归)仅仅添加js目录(未包含下面任何文件夹和文件)到版本控制(并未提交到版本库)
ex : svn add js --non-recursive
svn commit(ci) - 提交修改到服务端(创建一个新版本号)
# 提交一个index.php二进制文件到版本库并添加注释
ex : svn ci -m "this is index.php" index.php
# 提交一个index.php二进制文件到版本库但不想添加注释,由于 svn ci 命令必须包含注释,只能将注释留 "" 来到达这个需求了
ex : svn ci -m "" index.php
# 提交一个pic.png树文件到版本库并添加注释
ex : svn ci -m "this is pic.png" pic.png
# (递归)提交一个css目录及下面所有文件夹和文件到版本版本库并添加注释
ex : svn ci -m "this is css dir" css
# 提交当前目录版本控制下的所有文件目录及文件
ex : svn ci -m "" *
svn update(up) - 更新工作副本
# 更新当前目录的工作副本
ex : svn up
# 将index.php二进制文件更新至版本1
ex : svn up -r index.php
# 强制更新当前目录到最新版本
ex : svn up *
svn delete(del,remove,rm) - 从版本库中删除文件和目录
# 删除index.php二进制文件到版本控制(并未提交到版本库)
ex : svn rm index.php
# 删除pic.png树文件到版本控制(并未提交到版本库)
ex : svn rm pic.png
# (递归)删除css目录及下面所有文件夹和文件到版本控制(并未提交到版本库)
ex : svn rm css
svn diff(di) - 比较当前工作副本和最新版本库之间的差异
# 比较当前工作副本中的index.php和最新版本库中的index.php之间的差异
ex : svn di index.php
# 比较当前工作副本中的index.php和版本库版本2中的index.php之间的差异
ex : svn di -r index.php
# 比较版本库版本2中的index.php和版本库版本3中的index.php之间的差异
ex : svn di -r : index.php
# 比较当前工作副本和最新版本库所有文件目录和文件之间的差异
ex : svn di
svn mkdir - 创建一个文件夹到版本控制中
# 创建 doc 文件夹到版本控制中
ex : svn mkdir doc
->- mkdir doc
->- svn add doc
svn cat - 在不检出的情况查看文件内容
# 查看 svn://ip/index.php 文件内容
ex : svn cat svn://ip/index.php
svn revert - 工作副本进行还原操作
# 工作副本中的index.php还原至最新版本库中的index.php
ex : svn revert index.php
# 将工作副本所有文件目录和文件还原至最新版本库
ex : svn revert *
# (递归)将工作副本所有文件目录下文件和文件还原至最新版本库
ex : svn revert --recursive *
###
### 冲突及冲突解决办法
###
svn resolve - 弹出冲突解决选项
# 现有index.php冲突了,必须解决它,弹出选项
ex : svn resolve index.php
-> Select: (p) postpone(推迟), (df)show diff(显示差异), (e) edit file(编辑文件), (m) merge(合并), (mc) my side of conflict(采用我的文件), (tc) their sidee of conflict(采用他的文件), (s) show all options(显示所有选项): mc(并且告知svn服务器冲突已处理)
-> Resolved conflicted state of 'index.php'(冲突已解决,采用我的文件)
# 需要提交解决了的冲突文件至版本库中
svn ci -m "" index.php
->Sending index.php
->Transmitting file data .
->Committed vevision (old+).
# 冲突已经完美解决了,但是我们需要避免冲突,再编写程序或者其他什么操作之前更新至最新版本
###
### 加锁和解锁机制(不推荐使用)
###
svn lock - 加锁
# 将当前工作副本中的index.php加锁至版本控制中
ex : svn lock index.php
# 此时别人不能操作文件
# 如果修改index.php提交至版本库中,则会自动解锁。但是如果一直未改变该文件也未去解锁的话就会造成项目组其他人一直不能操作该文件,比如该人员辞职了,那么后果你可以想想,所以建议避免使用
svn unlock - 解锁
# 将当前工作副本中的index.php解锁至版本控制中
ex : svn unlock index.php
# 提交解锁文件
# svn ci -m "" --no-unlock index.php

多项目管理配置方案

常见 SVN 客多项目

# 步骤1: 创建svn多项目管理配置文件目录
mkdir /var/svn
# 步骤2: 创建svn配置文件目录
mkdir /var/svn/svnconfig
# 步骤3: 创建第一个项目
svnadmin create /var/svn/pigeonfan
# 步骤3: 创建第二个项目
svnadmin create /var/svn/mall
# 步骤3: 创建第三个项目
svnadmin create /var/svn/hardware
# 步骤4: 拷贝任意一个项目conf文件目录下所有文件至svn配置文件目录
cp /var/svn/pigeonfan/conf/* /var/svn/svnconfig/
# 步骤5: 删除svn配置文件目录的svnserve.conf
rm -f svnserve.conf
# 步骤6: 修改/var/svn/svnconfig/passwd文件
# 步骤7: 修改/var/svn/svnconfig/authz文件
# [groups]
# admin_group=admin
# [pigeonfan:/]
# @admin_group=rw
# *=
# [mall:/]
# @admin_group=rw
# *=
# [hardware:/]
# @admin_group=rw
# *=
vim /var/svn/svnconfig/authz
# 步骤8: 修改pigeonfan、mall、hardware下面的svnserve.conf,统一修改成
# anon-access = none
# auth-access = write
# password-db = /var/svn/svnconfig/passwd
# authz-db = /var/svn/svnconfig/authz
# 建议修改一个进行覆盖替换即可
# cp -f /var/svn/pigeonfan/svnserve.conf /var/svn/mall/svnserve.conf
# cp -f /var/svn/pigeonfan/svnserve.conf /var/svn/hardware/svnserve.conf
vim /var/svn/pigeonfan/svnserve.conf
vim /var/svn/mall/svnserve.conf
vim /var/svn/hardware/svnserve.conf
# 步骤9: 重启svn服务器
svnserve -d -r /var/svn

 如果继续添加版本库或者后续工作需要添加版本库,请按下面步骤操作就OK了:

### 如果后续有需要继续添加更多版本库的话
# 步骤1: 创建一个新的版本库
svnadmin create /var/svn/newrule
# 步骤2: 复制覆盖掉新的版本库中的svnserve.conf文件
cp /var/svn/pigeonfan/conf/svnserve.conf /var/svn/newrule/conf/svnserve.conf
# 步骤3: 将/var/svn/svnconfig/authz文件添加权限
# [newrule:/]
# @admin_group = rw
# * =

ok!后续会将基础操作写入博客,敬请期待!!

****************************************************************************************************************

写到最后:

### 可能会用到一些常用指令
# 查看服务
netstat -tnlp
# 查看svn服务启动没有
ps -aux|grep svn
# 如何清除SVN保存的用户和密码
rm ~/.subversion/auth/svn.simple/*
# kill掉svn进程(-9强制的意思)
kill -9 1131
# 重启svn服务(-d作为服务后台进行运行)(-r将后面的目录作为svn运行的根目录)
kill -9 1131 # 先强制kill调svn进程
svnserve -d -r /var/svn # 然后启动svn服务进程

在centos7下安装svn的更多相关文章

  1. CentOS7下安装SVN服务端

    CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...

  2. [转]CentOS7 下安装svn

    1. 安装 centos(我这里使用的是CentOS7)下yum命令即可方便的完成安装 $ sudo yum install subversion 测试安装是否成功: $ svnserve --ver ...

  3. Centos7 下的SVN安装与配置

    Centos7 下的SVN安装与配置 1.关闭防火墙 临时关闭防火墙 systemctl stop firewalld 永久防火墙开机自关闭 systemctl disable firewalld 临 ...

  4. SVN CentOS7 下配置svn的安装及基础配置介绍

    CentOS7 下配置svn的安装及基础配置介绍 by:授客 QQ:1033553122 目录 一. 二. 三. 四. 五. 六. 七. 一.      实践环境 CentOS 7操作系统(CentO ...

  5. CentOS7 下 安装 supervisor以及使用

    CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...

  6. Linux CentOs7 下安装 redis

    Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装  命令如下 $ yum install gcc-c++ $ wget ht ...

  7. Centos7下安装配置Redsocks

    Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...

  8. centOS7下安装GUI图形界面

    1.如何在centOS7下安装GUI图形界面 当你安装centOS7服务器版本的时候,系统默认是不会安装GUI的图形界面程序,这个需要手动安装CentOS7 Gnome GUI包. 2.在系统下使用命 ...

  9. CentOS7下安装MySQL并配置远程连接

    一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...

随机推荐

  1. 【IOS】iOS 企业版应用网站下载plist文件

    如果想从自己公司的网站上下载安装应用,首先 准备一个 index.html文件 <!DOCTYPE html> <html lang="zh-cn"> &l ...

  2. IMAP命令与分析

    https://www.cnblogs.com/crystalray/p/3304688.html Internet Mail Access Protocol(缩写为IMAP,以前称作交互邮件访问协议 ...

  3. eclipse安装maven时候如果conf文件夹中有setting文件则会以这个文件为主,如果自己设置了user的配置文件则会无效

    eclipse安装maven时候如果conf文件夹中有setting文件则会以这个文件为主,如果自己设置了user的配置文件则会无效

  4. sencha touch 2.2.1 自定义彩色图标按钮(button+ico)

    sencha touch 2.2.1 这个版本使用了新的按钮模式,不过他只提供了少部分的按钮样式.我们可以加一些自定义的ico样式 新加ico样式lower .x-button .x-button-i ...

  5. 搭建IPv4专有网络

    搭建IPv4专有网络 版权归属:阿里云网站   本教程将指引您搭建一个具有IPv4地址块的专有网络,并为专有网络中的ECS实例绑定一个弹性公网IP(EIP)进行公网访问. 步骤一:创建专有网络和交换机 ...

  6. gem install 和 bundle 区别

    bundle install 在设置了所有包含在Gemfile中的东西.你也可以传递参数. 如果在production模式下,你很清晰的区分了每个app需要的gems. gem install 则安装 ...

  7. Android图表开发——AChartEngine

    Android图表控件的开发 曾经开发过一个小程序,在Android电视机上面开发一个APP,用于显示一些统计图表的信息.最后找来找去基于Android Native开发有AChartEngine现成 ...

  8. 【BZOJ5094】硬盘检测 概率

    [BZOJ5094]硬盘检测 Description 很久很久以前,小Q买了一个大小为n单元的硬盘,并往里随机写入了n个32位无符号整数.因为时间过去太久,硬盘上的容量字眼早已模糊不清,小Q也早已忘记 ...

  9. Unity性能优化之Draw Call(转)

    Unity(或者说基本所有图形引擎)生成一帧画面的处理过程大致可以这样简化描述:引擎首先经过简单的可见性测试,确定摄像机可以看到的物体,然后把这些物体的顶点(包括本地位置.法线.UV等),索引(顶点如 ...

  10. centos 6.6编译安装nginx

    nginx 安装 安装前必要软件准备 1)安装pcre.gzip 等为了支持rewrite功能,我们需要安装pcre # yum install -y pcre* zlib zlib-devel op ...