linux 搭建svn服务器

安装svn

以本机ubuntu为例

sudo apt-get  svn

 Svn 安装

再讲述SVN的安装步骤时,先了解一下svn的工作原理
我们用一个小小的例子,引出svn;如果有一个项目,需要多个人员共同开发,但这些开发人员并不在一个地方,那如何来完成这个项目呢,每一个项目人员对一些文件或者程序的更改,如何能更快的被其他项目人员获得呢?这时候我们就需要一款管理项目开发程序的管理软件了,可是如何解决项目程序的同步问题、安全问题、以及管理问题呢?
SVN是近期崛起的一款管理软件,是csv的接班人,目前较多开源软件都是用svn作为管理软件
SVN的基本工作思路:在一台server上搭建一个源代码库,库里可以存放许多不同的源程序,由源代码库管理员统一管理这些源程序,每一个用户在使用这些源程序时,都需要将源代码库里的文件下载到本地,之后开发人员可以在本地进行修改,修改后用svn的命令提交,再由源代码库统一管理修改
解决的问题:
代码管理混乱
解决代码冲突管理困难
在代码整合期间引起bug
无法对拥有者进行适当的权限控制
项目不同,版本的发布困难
现在来讲解一些svn的安装步骤:
在这里不仅仅会介绍svn的安装,还会介绍一些配置,以及在win客户端下的使用
我现在是在centos 5.3版本上安装的,你前期需要准备的是有gcc这个编译器,最好能搭建一个YUM,这样可以帮你解决在安装过程中,缺少一些包的问题,本地源服务器YUM的安装,可参考:
http://1413570.blog.51cto.com/1403570/631226  
接下来就开始我们的辛酸之旅,途中会遇到很多困难哦,加油吧!
先下载两个包,
subversion-1.7.2.tar.gz
subversion-deps-1.6.1.tar.gz
这两个包,可以从 http://down.51cto.com/data/314148  下载
解压:
tar -zxvf subversion-1.7.2.tar.gz 
tar -zxvf subversion-deps-1.6.1.tar.gz 
进入目录,准备编译安装:
[root@localhost software]# cd subversion-1.7.2
[root@localhost subversion-1.7.2]# 指定安装的路径是在home下面,zlib需要zlib-devel- ,查了一下这个包是FSFS文件系统用到的包
安装遇到的第一个error,
checking for APR... no
configure: WARNING: APR not found
The Apache Portable Runtime (APR) library cannot be found.
Please install APR on this system and supply the appropriate
--with-apr option to 'configure'
解决办法:
到tar -zxvf subversion-deps-1.6.1.tar.gz 解压的目录下,有一个apr的文件夹,放到subversion-1.7.2下即可
[root@localhost subversion-1.7.2]# cp -rf ../subversion-1.6.1/apr .
Ok,再重新执行./configure 命令
遇到第二个error:
checking APR version... 1.3.3
configure: Apache Portable Runtime Utility (APRUTIL) library configuration
checking for APR-util... no
configure: WARNING: APRUTIL not found
The Apache Portable Runtime Utility (APRUTIL) library cannot be found.
Either install APRUTIL on this system and supply the appropriate
提示的是apache的端口没有找到,因为此安装并没有与apache结合,到tar -zxvf subversion-deps-1.6.1.tar.gz 解压的目录下,发现有一个 APR-util,再移动到ubversion-1.7.2下
重新执行./configure 命令
Ok,遇到第三个error,
checking sqlite library version (via pkg-config)... no

An appropriate version of sqlite could not be found. We recommmend
3.7.6.3, but require at least 3.6.18.
错误有提示:解决办法
get the sqlite 3.7.6.3 amalgamation from:
http://www.sqlite.org/sqlite-amalgamation-3.7.6.3.tar.gz
unpack the archive using tar/gunzip and copy sqlite3.c from the
resulting directory to:
/home/software/subversion-1.7.2/sqlite-amalgamation/sqlite3.c
下载这个包,解压,将sqlite3.c放到指定的位置
http://down.51cto.com/data/314253  
下载,解压
unzip sqlite-amalgamation-3070900.zip 
[root@localhost software]# mkdir -p subversion-1.7.2/sqlite-amalgamation
[root@localhost software]# cd sqlite-amalgamation-3070900
[root@localhost sqlite-amalgamation-3070900]# cp sqlite3.c ../subversion-1.7.2/sqlite-amalgamation/
之後重新執行./configure
见到这表示。、config执行ok 
checking for ctypesgen.py... none
configure: creating ./config.status
config.status: creating Makefile
config.status: creating tools/backup/hot-backup.py
config.status: creating tools/hook-scripts/commit-access-control.pl
config.status: creating subversion/bindings/swig/perl/native/Makefile.PL
config.status: creating subversion/svn_private_config.h.tmp
config.status: executing libtool commands
config.status: executing svn_private_config.h.tmp commands
[root@localhost subversion-1.7.2]# make clean[
root@localhost subversion-1.7.2]# make && make install 
只要没有遇到error,就是ok的,
cd subversion/po ; /usr/bin/install -c -m 644 zh_TW.mo /home/svn/share/locale/zh_TW/LC_MESSAGES/subversion.mo
test -d /home/svn/include/subversion-1 || \
/usr/bin/install -c -d /home/svn/include/subversion-1
(subversion/svnversion/svnversion . 2> /dev/null || \
svnversion . 2> /dev/null || \
echo "unknown"; \
) > /home/svn/include/subversion-1/svn-revision.txt
[root@localhost subversion-1.7.2]# 
现在在home下面可以找到svn这个目录,说明我们的安装已经结束,[root@localhost home]# cd svn/
[root@localhost svn]# ls
bin build-1 include lib share
[root@localhost svn]# pwd
/home/svn
[root@localhost svn]# 
要让系统找到这些命令还需要将这些命令添加到系统的环境变量中。 操作为
Vi /etc/profile
找到export PATH 
export PATH=/home/svn/bin:$PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
命令:[root@localhost bin]# source /etc/profile 
让profile文件生效

配置svn
建立用户

localhost ~ # useradd svn
localhost ~ # PATH=$PATH:/usr/local/subversion/bin 
localhost ~ # export PATH #把SVN命令加到默认路径

 
建立版本库目录,可建多个:

localhost ~ # mkdir –p /svndata/repos1
localhost ~ # mkdir  /svndata/repos2

 
建立版本库:

localhost ~ # svnadmin create /svndata/repos1
localhost ~ # svnadmin create /svndata/repos2

 
以版本库1为例,配置版本库1:

localhost ~ # cd /svndata/repos1/
localhost repos1 # ls
README.txt  conf  db  format  hooks  locks

 
看到上面目录与文件,说明版本库创建成功。
配置文件有如下三个:

localhost repos1 # ls conf/
authz          passwd         svnserve.conf

 
配置svnserve.conf:

localhost repos1 # vi conf/svnserve.conf
[general]
anon-access = none #去掉“#”将值“read”修改为“none”
auth-access = write
password-db = passwd
authz-db = authz

 
注:去掉这几行前面的“#”并前面不可以有空格,否则会报错
配置 passwd:

localhost repos1 # vi conf/passwd
[users]
liwei = 12345 #添加的用户,后面为密码
配置 authz:
[aliases] #此选项按默认
[groups]
admin = liwei #设置组,及其成员,添加用户使用“,”号隔开,如 admin=liwei,liwei1
[/] #设置根目录权限
liwei = rw
@admin = rw
[svndata:/repos1] #设置版本库1的权限
liwei = rw

 
四、 修改权限:

localhost ~ # chown svn:svn –R /svndata

 
五、 启动和停止SVN服务:
启动SVN服务:

localhost ~ # svnserve -d -r /svndata/

 
查看服务是否正常启动:

localhost ~ # netstat -auntp |grep 3690
tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN      20562/svnserve

 
停止SVN服务:

localhost ~ # killall svnserve

 
把某个目录里的资料加入到版本库里的方法:

localhost ~ # svn import directory/  file:///svndata/repos1 (把directory目录下的资料加入到版本库repos1里面)

 

客户端连接





错误:
svn: None of the environment variables SVN_EDITOR...问题解决 
问题1:
svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found
问题原因:

没有设置svn编辑器的环境变量,主要是import、commit中填写comment要用

解决办法:

编辑 /etc/bashrc 文件,加入如下一行:

export SVN_EDITOR=vim
温馨提示:
编辑完以后一般需要让配置文件立即生效,可执行命令:
source  /etc/bashrc

猜你喜欢

转载自leonlulu1221.iteye.com/blog/2082794