开发人员经常会上传代码,或者改对代码做一些更改。svn就是用来将修改后的代码更新到服务器上的。下面就来看一下怎么在Linux环境下搭建svn服务(subversion)。

步骤:

1、检查是否已经有svn

2、安装subversion

3、检查是否安装成功

4、创建svn资源仓库

5、新增用户及密码,配置权限,配置资源库权限

6、启动或者重启服务

7、从机安装subversion

8、测试

一、检查是否已经有svn

如果没有安装就会是下面的样子,提示找不到命令。

[root@localhost ~]# svnserve --version

-bash: svnserve: command not found

如果已经安装,会显示版本信息:

[root@localhost ~]# svnserve --version

svnserve, version 1.6.11 (r934486)

compiled Aug 17 2015, 08:37:43

Copyright (C) 2000-2009 CollabNet.

Subversion is open source software, see http://subversion.tigris.org/

This product includes software developed by CollabNet (http://www.Collab.Net/).

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.

二、安装

在Linux下安装的是subversion,直接用yum 安装即可。

[root@localhost ~]#

[root@localhost ~]# yum install -y subversion

三、检查安装是否成功

同样用的是 svnserve –version成功安装会显示版本信息

[root@localhost ~]# svnserve --version

四、创建svn资源仓库

配置文件就是在这一步生成。

[root@localhost ~]# svnadmin create /svndir

[root@localhost ~]# cd /svndir/

[root@localhost svndir]# ls

conf db format hooks locks README.txt

[root@localhost svndir]# cd conf/

[root@localhost conf]# ls

authz passwd svnserve.conf

五、新增用户及密码,配置权限

已经看到在仓库下面生成了三个文件

authz #权限配置文件

passwd #用户名密码文件

svnserve.conf #资源库配置文件

[root@localhost conf]# 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

yunwei = 123456

~

新增一行:

yunwei = 123456

新增用户“yunwei”,密码是“123456”

[root@localhost conf]# vim authz

[groups]

# harry_and_sally = harry,sally

# harry_sally_and_joe = harry,sally,&joe

[/]

* = r

@admin = rw

dangerman =

[svndir:/]

@admin = rw

在[groups]下面加入:

* = r #所有用户有读权限

dangerman = ##危险分子?什么是危险分子?没有任何权限

[svndir:/] ###定义目录,项目的根目录

* = rw

[root@localhost conf]# vim svnserve.conf

这个配置文件打开下面几行前面的注释,删除最前面的空格:

anon-access = read

auth-access = write

password-db = passwd

authz-db = authz

realm = My First Repository

六、启动或者重启服务

[root@localhost conf]# /etc/init.d/svnserve start

Starting svnserve: [ OK ]

如果要指定目录要加参数:

[root@localhost svndir]# mkdir /svndir/svn

[root@localhost svndir]# svnserve -d -r /svndir/svn ####(只是看一下可以指定目录,这个实验不需要)

svnserve: Can't bind server socket: Address already in use

问题来了!!!问题来了:

显示Address already in use

原因在这里:svnserve -d -r /svndir/svn 这条命令就是指定目录的启动。但是前面已经启动一次了。解决办法:

[root@localhost svndir]# /etc/init.d/svnserve stop

Stopping svnserve: [ OK ]

[root@localhost svndir]# svnserve -d -r /svndir/

[root@localhost svndir]# ls

conf db format hooks locks README.txt

[root@localhost svndir]# netstat -antlp | grep svn

tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 5045/svnserve

七、测试,从机安装subversion

在次从机安装也安装一个subversion 用来测试。

注:

服务主机:192.168.1.65

从机:192.168.1.121

在从机上checkout 根目录

[root@localhost ~]# svn checkout svn://192.168.1.65/svndir/

Checked out revision 0.

需要注意的这里check的目录跟服务主机里面定义的[svndir]要一样。

[root@localhost ~]# svn checkout svn://192.168.1.65/svndir/

svn: URL 'svn://192.168.1.65/svndir' doesn't exist

如果出现在这个报错,就要检查服务主机的auth配置文件了:

如果配置文件的的目录指定的是[svndir:/],而且svndir的目录在根下(/svndir)

那启动的时候即嫑指定目录直接用/etc/init.d/svnserve start 启动即可。我们这里目录符合默认目录,不用指定了。直接用/etc/init.d/svnserve start,或者不用指定目录。

svnserve -d -r /svndir/ 这表示指定目录到/svndir/

目录不对应会报错。

7.1:在从机上从机:192.168.1.121上提交

[root@localhost ~]# ls

Desktop Downloads Pictures svndir Videos

Documents Music Public Templates

[root@localhost ~]# cd svndir/

[root@localhost svndir]# ls

[root@localhost svndir]# touch xiao

[root@localhost svndir]# ls

xiao

[root@localhost svndir]# pwd

/root/svndir

[root@localhost svndir]# ls

xiao

[root@localhost svndir]# svn add /root/svndir/xiao

A /root/svndir/xiao

[root@localhost svndir]# svn commit /root/svndir/xiao -m 1

Authentication realm: My First Repository

Password for 'root':

Authentication realm: My First Repository

Username: ^Csvn: Commit failed (details follow):

n: Caught signal

[root@localhost svndir]# svn commit /root/svndir/xiao -m 1

Authentication realm: My First Repository

Password for 'root':

Authentication realm: My First Repository

Username: yunwei

Password for 'yunwei':

-----------------------------------------------------------------------

ATTENTION! Your password for authentication realm:

My First Repository

can only be stored to disk unencrypted! You are advised to configure

your system so that Subversion can store passwords encrypted, if

possible. See the documentation for details.

You can avoid future appearances of this warning by setting the value

of the 'store-plaintext-passwords' option to either 'yes' or 'no' in

'/root/.subversion/servers'.

-----------------------------------------------------------------------

Store password unencrypted (yes/no)? yes

Adding xiao

Transmitting file data .

Committed revision 1.

注意:

1、提交代码前,必须先cd到/root/svndir/(就是checkout下来的)目录里;

2、服务器上没有的文件,在客户端需要先add预提交,再commit,如果服务器端已有的文件,直接commit

预提交的命令:

svn add /root/svndir/xiao

提交的命令:

svn commit /root/svndir/xiao -m 1

出现committed revision 1 提交成功了。

到服务端查看有没有提交成功:

服务主机:192.168.1.65

[root@localhost svndir]# svn checkout svn://192.168.1.65/svndir/

A svndir/xiao

Checked out revision 1.

[root@localhost svndir]# ls

conf db format hooks locks README.txt svn svndir

[root@localhost svndir]# cd svndir/

[root@localhost svndir]# ls

xiao

接下来测试更新:

从机:192.168.1.121:

[root@localhost svndir]# ls

xiao

[root@localhost svndir]# vim xiao

hello koby bryant !

~

修改了xiao 这个文件的内容,之前是空文件,现在加上一行内容。

然后重新提交:

[root@localhost svndir]# svn commit /root/svndir/xiao -m 2

Sending xiao

Transmitting file data .

Committed revision 2.

服务器主机:192.168.1.65

[root@localhost svndir]# svn up

xiao

Updated to revision 2.

[root@localhost svndir]# ls

xiao

[root@localhost svndir]# vim xiao

hello koby bryant !

~

内容已经更改。

因为是更改内容,目录和文件已经有了,所以不用checkout了,直接svn up就可以了。

7.2、在服务器主机:192.168.1.65上提交

[root@localhost svndir]# ls

xiao yao

[root@localhost svndir]# pwd

/svndir/svndir

[root@localhost svndir]# svn add /svndir/svndir/yao

A /svndir/svndir/yao

[root@localhost svndir]# svn commit /svndir/svndir/yao -m 3

Authentication realm: My First Repository

Password for 'root':

Authentication realm: My First Repository

Username: yunwei

Password for 'yunwei':

-----------------------------------------------------------------------

ATTENTION! Your password for authentication realm:

My First Repository

can only be stored to disk unencrypted! You are advised to configure

your system so that Subversion can store passwords encrypted, if

possible. See the documentation for details.

You can avoid future appearances of this warning by setting the value

of the 'store-plaintext-passwords' option to either 'yes' or 'no' in

'/root/.subversion/servers'.

-----------------------------------------------------------------------

Store password unencrypted (yes/no)? yes

Adding yao

Transmitting file data .

Committed revision 3.

注意:还是要cd到/svndir/svndir里面再预提交,然后提交。

显示Committed revision 3.就说明提交成功

到从机:192.168.1.121上更新看效果:

[root@localhost svndir]# svn up

A yao

Updated to revision 3.

[root@localhost svndir]# ls

xiao yao

[root@localhost svndir]# cat yao

hello rayallen

上面提交不管是在服务器主机上还是在从机上,都需要输入服务器主机的root用户密码,以及在conf文件里面设置的用户和密码。上面测试是用的文件测试,目录同样可以。

比如:

从机上:192.168.1.121

[root@localhost svndir]# mkdir xiaoyao

[root@localhost svndir]# ls

xiao xiaoyao yao

[root@localhost svndir]# svn add /root/svndir/xiaoyao/

A /root/svndir/xiaoyao

[root@localhost svndir]# svn commit /root/svndir/xiaoyao/ -m 4

Adding xiaoyao

Committed revision 4.

服务器主机上:192.168.1.65

[root@localhost svndir]# svn up

A xiaoyao

Updated to revision 4.

[root@localhost svndir]# ls

xiao xiaoyao yao

至此,svn的安装配置测试就成功了

linux上svn的使用教程,Linux上SVN的搭建使用相关推荐

  1. linux死锁的例子,操作系统教程—Linux实例分析 孟庆昌 第8章 死锁new.ppt

    操作系统教程-Linux实例分析 孟庆昌 第8章 死锁new.ppt 第8章 死锁 8.1 概述 8.2 产生死锁的条件 8.3 死锁的预防 8.4 死锁的避免 8.5 死锁的检测与恢复 8.6 处理 ...

  2. Linux服务器部署ssl证书教程,linux服务器在wdcp面板安装ssl证书教程

    不少站长如今越来越在意站内数据传输的安全性,想着把自己建设的网站加密传输,许多站长都需要安装ssl证书,且很多站长都在找寻centos系统服务器linux服务器或者是wdcp面板怎么安装ssl证书,网 ...

  3. linux下分区ntfs,简易教程:Linux下NTFS分区的写操作

    Linux下NTFS分区的写操作只需通过简单点击即可完成. 在你正常的工作中,假如你装的是双系统,其中一个是Winodws系统,而你又在Linux环境下办公,需要用到Windows分区中的某文档资料或 ...

  4. linux下eclipse基本使用教程,linux eclipse 使用教程

    linux eclipse 使用教程 [2021-02-14 16:47:19]  简介: php去除nbsp的方法:首先创建一个PHP代码示例文件:然后通过"preg_replace(&q ...

  5. Linux综合实训案例教程,Linux操作系统教程-实训与项目案例原稿.ppt

    Linux操作系统教程-实训与项目案例原稿分析 第11章 Bash 使用详解 本章内容 Shell概念 Linux下用户Shell的指定 Bash的使用 Bash的常见技巧与快捷键 Bash的变里使用 ...

  6. linux下eclipse的使用教程,linux下Eclipse的使用方法总结.doc

    linux下Eclipse的使用方法总结 安装的版本 jdk-6u7-linux-i586.bin eclipse-cpp-ganymede-SR1-linux-gtk.tar.gz 主机方面的设置 ...

  7. Linux刻录固态硬盘教程,linux迁移至固态硬盘全过程

    自从台式机上用上固态硬盘后,就再也受不了笔记本上的5400转的机械硬盘了,所以这次又买了块固态硬盘打算装到笔记本上. 笔记本里装的是Ubuntu 14.04 + Win7双系统,Win7主要偶尔运行一 ...

  8. app文件上传到服务器教程,app上传文件到云服务器

    app上传文件到云服务器 内容精选 换一换 本节操作以CentOS操作系统为例,介绍配置SFTP.使用SFTP上传或下载文件.文件夹的操作步骤.以root用户登录云服务器.执行以下命令查看ssh版本, ...

  9. linux 多硬盘 多分区教程,Linux下硬盘分区的最佳方案

    在对硬盘进行分区前,应该先弄清楚计算机担负的工作及硬盘的容量有多大,还要考虑到以下几个问题. 第一点也是最重要的一点,要知道当前安装LILO的版本,因为LILO2.21及早期版本对硬盘大小有限制,如果 ...

最新文章

  1. selenium+python自动化81-html报告优化(饼图+失败重跑+兼容python23)
  2. 怎么把位域合成一个字节_C语言中字节对齐和位域
  3. X-007 FriendlyARM tiny4412 u-boot移植之内存初始化
  4. 调用webservice或wcf时,提示:无法加载协定为的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选的终结点配置部分。
  5. [kuangbin]各种各样的题单
  6. 【TPC协议头解析】
  7. Android 驱动(3)---Android驱动开发知识储备
  8. Netty学习总结(1)——Netty入门介绍
  9. 显示表格数据网页php源码,网页上可以复制的表格数据,为什么察看源代码找不到这些数据?_html/css_WEB-ITnose...
  10. 专家教你简单又轻松的MD5解密方法,一看就会
  11. php gd 缩小,php 使用GD缩小图片,使用透明格式就失真
  12. Maven子父工程依赖配置,小白也能看得懂
  13. form表单提交方式
  14. matlab horn antenna,antennas 天线阵列设计的matlab源码,非常有用 238万源代码下载- www.pudn.com...
  15. 不懂就问,苹果电脑格式化了能恢复数据吗?
  16. 【金融项目】尚融宝项目(九)
  17. 【BZOJ2002】【HNOI2010】弹飞绵羊(LCT)
  18. 关于超细六类网线用于PoE的说明
  19. python求平均数和中位数
  20. 码出一个高颜值原生折线图(新增柱状图、环形图)

热门文章

  1. 【Kafka】Kafka Producer整体架构概述及源码分析
  2. 95-10-092-启动-TokenManager
  3. javacc解析json报错
  4. Spring: ConfigurationClassUtils类
  5. Spring : 缓存相关注解@EnableCaching、@CacheConfig、@Cacheable、@Caching
  6. Spring : Spring @Transactional 事物管理入口
  7. Android获取图片资源的4种方式
  8. 云计算实战系列六(Linux进程管理)
  9. Java关键字:final,static,this,super
  10. 交互式地图_张晟推出学校资源交互式地图工具