CentOS安装并配置基于Apache的SVN服务器
时间:2015-12-14 15:28 来源:linux.it.net.cn 作者:IT
在Linux服务器上安装并配置基于Apache的SVN服务器:
#
# 1、安装服务,需要安装如下程序包:
# subversion
# httpd
# mod_dav_svn
#
[root@svn-server ~]
# yum install subversion httpd mod_dav_svn -y
#
# 2、创建svn版本库
#
# 创建存放svn版本库的目录/svn
#
[root@svn-server ~]
# mkdir /svn
#
# 在/svn目录下使用svnadmin命令创建svn版本库repot,然后查看创建好的svn版本库
#
[root@svn-server ~]
# svnadmin create /svn/repot
[root@svn-server ~]
# ll /svn/repot
total 24
drwxr-xr-x. 2 root root 4096 Dec 13 22:52 conf
drwxr-sr-x. 6 root root 4096 Dec 13 22:52 db
-r--r--r--. 1 root root 2 Dec 13 22:52
format
drwxr-xr-x. 2 root root 4096 Dec 13 22:52 hooks
drwxr-xr-x. 2 root root 4096 Dec 13 22:52 locks
-rw-r--r--. 1 root root 229 Dec 13 22:52 README.txt
#
# 3、创建svn用户
#
# 使用htpasswd命令创建用户配置文件
# -c 第一次创建用户的时候,同步创建用户配置文件(仅第一次)
# -b 在htpasswd命令中明文配置密码
# -m 使用MD5对密码进行加密
# /svn/repot/conf/passwd 用户配置文件位置,文件名和存放目录没有要求
# admin 用户名
# 123456 admin密码,因为前面使用了 -b 选项,所以必须在后面加上密码
#
[root@svn-server ~]
# htpasswd -c -b -m /svn/repot/conf/passwd admin 123456
Adding password
for
user admin
#
# 创建第二个用户的时候就不需要 -c 选项了
# 不指定加密选项则在Linux上默认使用 -d 选项,crypt加密
# 不使用 -b 选项,则会提示你输入两次没有回显的密码,两次密码必须一致
#
[root@svn-server ~]
# htpasswd /svn/repot/conf/passwd rouser
New password:
Re-
type
new password:
Adding password
for
user rouser
#
# 查看用户配置文件:admin密码使用MD5加密,rouser密码使用crypt加密
#
[root@svn-server ~]
# cat /svn/repot/conf/passwd
admin:$apr1$R6KbqLSX$UwXTcVK6iCRfxlfyIbO4z/
rouser:UBx6tRs3XYOwI
#
# 4、配置svn权限
#
# 我们使用默认的svn权限配置文件进行配置,文件名和存放目录没有要求
#
[root@svn-server ~]
# cat /svn/repot/conf/authz
[
groups
]
#定义用户组,方便统一管理
all = admin,rouser
#定义一个组叫做“all”,包含“admin”和“rouser”
[/]
#定义svn版本库根目录权限(子目录继承根目录权限)
* = r
#所有用户有读权限
@all = r
#用户组“all”中的所有用户有读权限
admin = rw
#admin用户有读权限和写权限
rouser = r
#rouser有读权限
#
# 5、配置http访问
#
# 编辑Apache配置文件 /etc/httpd/conf.d/subversion.conf
#
[root@svn-server ~]
# cat /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules
/mod_dav_svn
.so
#加载dav_svn模块
LoadModule authz_svn_module modules
/mod_authz_svn
.so
#加载authz_svn模块
<Location
/repot
>
#针对repot版本库做访问配置
DAV svn
#
SVNPath
/svn/repot
#repot版本库路径
AuthzSVNAccessFile
/svn/repot/conf/authz
#访问权限配置文件
AuthType Basic
#http验证方式:Basic
AuthName
"Authorization repot SVN"
#验证提示语
AuthUserFile
/svn/repot/conf/passwd
#用户配置文件
Require valid-user
#限定用户只有输对了用户名和密码才能访问
Satisfy Any
#ip没有被禁止或者完成账号密码验证就能访问
<
/Location
>
#
# 设置svn版本库下的目录和文件的所有者和属组为apache,允许通过http访问的用户可以读写svn版本库中的文件
#
[root@svn-server ~]
# chown -R apache.apache /svn/
[root@svn-server ~]
# ll /svn/
total 4
drwxr-xr-x. 6 apache apache 4096 Dec 13 22:52 repot
#
# 重启http服务
#
[root@svn-server ~]
# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
#
# 设置svn服务开机启动
#
[root@svn-server ~]
# chkconfig httpd on
[root@svn-server ~]
# chkconfig --list |grep httpd
httpd 0:off1:off2:on3:on4:on5:on6:off
#
# 注意配置好防火墙和SELinux,为了方便验证,可以临时关闭防火墙和SELinux
#
# 在浏览器或者svn客户端中访问 http://svn-server_ip/repot 验证svn已经可以访问
#
# admin用户有读权限和写权限,rouser只有读权限
#
#########################################################################################################
#
# 修改用户配置文件和svn权限后立即生效,不需要重启服务
#
# 删除用户
#
[root@svn-server ~]
# htpasswd -D /svn/repot/conf/passwd rouser
Deleting password
for
user rouser
[root@svn-server ~]
# cat /svn/repot/conf/passwd
admin:$apr1$R6KbqLSX$UwXTcVK6iCRfxlfyIbO4z/
#
# 重置密码,先使用crypt加密,后使用MD5加密
#
[root@svn-server ~]
# htpasswd -b /svn/repot/conf/passwd admin 654321
Updating password
for
user admin
[root@svn-server ~]
# cat /svn/repot/conf/passwd
admin:dnCSoZ6Ja0drU
[root@svn-server ~]
# htpasswd -b -m /svn/repot/conf/passwd admin 111111
Updating password
for
user admin
[root@svn-server ~]
# cat /svn/repot/conf/passwd
admin:$apr1$xGna7avC$F6Tkpd8iHs2ESCsu2Psl0.
(责任编辑:IT)
在Linux服务器上安装并配置基于Apache的SVN服务器:
|