设为首页 收藏本站
查看: 970|回复: 0

[经验分享] 在Linux上安装并配置基于Apache的SVN服务器

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-12-14 10:09:59 | 显示全部楼层 |阅读模式
在Linux服务器上安装并配置基于Apache的SVN服务器:

    1、安装服务
    2、创建svn版本库
    3、创建svn用户
    4、配置svn权限
    5、配置http访问

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#
#    1、安装服务,需要安装如下程序包:
#        subversion
#        httpd
#        mod_dav_svn
#
[iyunv@svn-server ~]# yum install subversion httpd mod_dav_svn -y
#
#    2、创建svn版本库
#
#        创建存放svn版本库的目录/svn
#
[iyunv@svn-server ~]# mkdir /svn
#
#        在/svn目录下使用svnadmin命令创建svn版本库repot,然后查看创建好的svn版本库
#
[iyunv@svn-server ~]# svnadmin create /svn/repot
[iyunv@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 选项,所以必须在后面加上密码
#
[iyunv@svn-server ~]# htpasswd -c -b -m /svn/repot/conf/passwd admin 123456
Adding password for user admin
#
#        创建第二个用户的时候就不需要 -c 选项了
#        不指定加密选项则在Linux上默认使用 -d 选项,crypt加密
#        不使用 -b 选项,则会提示你输入两次没有回显的密码,两次密码必须一致
#
[iyunv@svn-server ~]# htpasswd /svn/repot/conf/passwd rouser
New password:
Re-type new password:
Adding password for user rouser
#
#        查看用户配置文件:admin密码使用MD5加密,rouser密码使用crypt加密
#
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:$apr1$R6KbqLSX$UwXTcVK6iCRfxlfyIbO4z/
rouser:UBx6tRs3XYOwI
#
#    4、配置svn权限
#
#        我们使用默认的svn权限配置文件进行配置,文件名和存放目录没有要求
#
[iyunv@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
#
[iyunv@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版本库中的文件
#
[iyunv@svn-server ~]# chown -R  apache.apache /svn/
[iyunv@svn-server ~]# ll /svn/
total 4
drwxr-xr-x. 6 apache apache 4096 Dec 13 22:52 repot
#
#        重启http服务
#
[iyunv@svn-server ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
#
#        设置svn服务开机启动
#
[iyunv@svn-server ~]# chkconfig httpd on
[iyunv@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权限后立即生效,不需要重启服务
#
#        删除用户
#
[iyunv@svn-server ~]# htpasswd -D /svn/repot/conf/passwd rouser
Deleting password for user rouser
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:$apr1$R6KbqLSX$UwXTcVK6iCRfxlfyIbO4z/
#
#        重置密码,先使用crypt加密,后使用MD5加密
#
[iyunv@svn-server ~]# htpasswd -b /svn/repot/conf/passwd admin 654321
Updating password for user admin
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:dnCSoZ6Ja0drU
[iyunv@svn-server ~]# htpasswd -b -m /svn/repot/conf/passwd admin 111111
Updating password for user admin
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:$apr1$xGna7avC$F6Tkpd8iHs2ESCsu2Psl0.



  在Linux服务器上安装并配置基于Apache的SVN服务器:

    1、安装服务
    2、创建svn版本库
    3、创建svn用户
    4、配置svn权限
    5、配置http访问

#
#    1、安装服务,需要安装如下程序包:
#        subversion
#        httpd
#        mod_dav_svn
#
[iyunv@svn-server ~]# yum install subversion httpd mod_dav_svn -y
#
#    2、创建svn版本库
#
#    创建存放svn版本库的目录    /svn
#
[iyunv@svn-server ~]# mkdir /svn
#
#    在/svn目录下使用svnadmin命令创建svn版本库repot,然后查看创建好的svn版本库
#
[iyunv@svn-server ~]# svnadmin create /svn/repot
[iyunv@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 选项,所以必须在后面加上密码
#
[iyunv@svn-server ~]# htpasswd -c -b -m /svn/repot/conf/passwd admin 123456
Adding password for user admin
#
#    创建第二个用户的时候就不需要 -c 选项了
#    不指定加密选项则在Linux上默认使用 -d 选项,crypt加密
#    不使用 -b 选项,则会提示你输入两次没有回显的密码,两次密码必须一致
#
[iyunv@svn-server ~]# htpasswd /svn/repot/conf/passwd rouser
New password:
Re-type new password:
Adding password for user rouser
#
#    查看用户配置文件:admin密码使用MD5加密,rouser密码使用crypt加密
#
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:$apr1$R6KbqLSX$UwXTcVK6iCRfxlfyIbO4z/
rouser:UBx6tRs3XYOwI
#
#    4、配置svn权限
#
#    我们使用默认的svn权限配置文件进行配置,文件名和存放目录没有要求
#
[iyunv@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
#
[iyunv@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版本库中的文件
#
[iyunv@svn-server ~]# chown -R  apache.apache /svn/
[iyunv@svn-server ~]# ll /svn/
total 4
drwxr-xr-x. 6 apache apache 4096 Dec 13 22:52 repot
#
#    重启http服务
#
[iyunv@svn-server ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
#
#    设置svn服务开机启动
#
[iyunv@svn-server ~]# chkconfig httpd on
[iyunv@svn-server ~]# chkconfig --list |grep httpd
httpd              0:off    1:off    2:on    3:on    4:on    5:on    6:off
#
#    注意配置好防火墙和SELinux,为了方便验证,可以临时关闭防火墙和SELinux
#
#    在浏览器或者svn客户端中访问 http://svn-server_ip/repot 验证svn已经可以访问
#
#    admin用户有读权限和写权限,rouser只有读权限
#
#########################################################################################################
#
#    修改用户配置文件和svn权限后立即生效,不需要重启服务
#
#    删除用户
#
[iyunv@svn-server ~]# htpasswd -D /svn/repot/conf/passwd rouser
Deleting password for user rouser
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:$apr1$R6KbqLSX$UwXTcVK6iCRfxlfyIbO4z/
#
#    重置密码,先使用crypt加密,后使用MD5加密
#
[iyunv@svn-server ~]# htpasswd -b /svn/repot/conf/passwd admin 654321
Updating password for user admin
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:dnCSoZ6Ja0drU
[iyunv@svn-server ~]# htpasswd -b -m /svn/repot/conf/passwd admin 111111
Updating password for user admin
[iyunv@svn-server ~]# cat /svn/repot/conf/passwd
admin:$apr1$xGna7avC$F6Tkpd8iHs2ESCsu2Psl0.




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-150852-1-1.html 上篇帖子: 启动apache 提示命令不存在 下篇帖子: 源码编译apache 服务器 Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表