作者:mobiledu2502894753 | 来源:互联网 | 2023-10-12 14:02
服务器端一、SVN配置1、IP地址[root@svn~]#catetcedhat-releaseCentOSLinuxrelease7.6.1810(Core)[root@svn~
服务器端
一、SVN配置
1、IP地址
[root@svn ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@svn ~]# ip add
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:a8:2a:50 brd ff:ff:ff:ff:ff:ff
inet 192.168.75.129/24 brd 192.168.75.255 scope global noprefixroute dynamic ens33
valid_lft 1777sec preferred_lft 1777sec
inet6 fe80::8e71:d2d2:6dc1:5f9d/64 scope link noprefixroute
valid_lft forever preferred_lft forever
2、临时关闭防火墙和selinux,根据需求可以永久关闭
[root@svn ~]# systemctl stop firewalld
[root@svn ~]# setenforce 0
3、安装subversion
[root@svn ~]# yum install -y subversion
4、查看svn版本
[root@svn ~]# svnserve --version
svnserve, version 1.7.14 (r1542130)
compiled Sep 30 2020, 17:44:04
Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/
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.
5、创建SVN版本库(项目仓库)
1、创建所有项目的根目录
[root@svn ~]# mkdir -p /data/svn
2、在根目录创建相关子项目目录XPH
[root@svn ~]# mkdir -p /data/svn/XPH
3、在子目录XPH创建三个所属版本库
[root@svn ~]# svnadmin create /data/svn/XPH/xph-art
[root@svn ~]# svnadmin create /data/svn/XPH/xph-backend
[root@svn ~]# svnadmin create /data/svn/XPH/xph-docs
4、在子目录XPH创建统一管理的用户密码和权限目录
[root@svn ~]# mkdir -p /data/svn/XPH/auth
5、查看结果
[root@svn ~]# ll /data/svn/XPH/
total 0
drwxr-xr-x. 2 root root 6 Dec 28 05:12 auth
drwxr-xr-x. 6 root root 86 Dec 28 05:08 xph-art
drwxr-xr-x. 6 root root 86 Dec 28 05:09 xph-backend
drwxr-xr-x. 6 root root 86 Dec 28 05:09 xph-docs
6、拷贝用户权限文件进行修改,名字对应项目版本库
1、拷贝文件(目前文件内容都一样)
[root@svn ~]# cd /data/svn/XPH/
[root@svn XPH]# cp xph-art/conf/authz auth/xph-art-auth
[root@svn XPH]# cp xph-backend/conf/authz auth/xph-backend-auth
[root@svn XPH]# cp xph-docs/conf/authz auth/xph-docs-auth
2、编辑xph-art-auth文件
[root@svn XPH]# vin /data/svn/XPH/auth/xph-art-auth
[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
admin = admin
Producter = art
[/]
@admin = rw
@Producter = rw
3、编辑xph-backend-auth文件
[root@svn XPH]# vi /data/svn/XPH/auth/xph-backend-auth
[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
admin = admin
Producter = backend
[/]
@admin = rw
@Producter = rw
4、编辑xph-docs-auth文件
[root@svn XPH]# vi /data/svn/XPH/auth/xph-docs-auth
[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
admin = admin
Producter = docs
[/]
@admin = rw
@Producter = rw
二、Apache配置
1、安装httpd、mod_dav_svn
[root@svn ~]# yum install -y httpd mod_dav_svn
2、检查apache、mod_dav_svn,安装成功会有两个文件mod_dav_svn.so和mod_authz_svn.so
[root@svn ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 10 2021 14:26:31
[root@svn ~]# find / -name mod_dav_svn.so
/usr/lib64/httpd/modules/mod_dav_svn.so
[root@svn ~]# find / -name mod_authz_svn.so
/usr/lib64/httpd/modules/mod_authz_svn.so
3、修改配置文件/etc/httpd/conf.d/subversion.conf(如果没有可以自己增加)
[root@svn ~]# vi /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
DAV svn
SVNPath /data/svn/XPH/xph-art
AuthType Basic
AuthName "Authorization SVN"
AuthzSVNAccessFile /data/svn/XPH/auth/xph-art-auth
AuthUserFile /data/svn/XPH/auth/passwd
Require valid-user
DAV svn
SVNPath /data/svn/XPH/xph-backend
AuthType Basic
AuthName "Authorization SVN"
AuthzSVNAccessFile /data/svn/XPH/auth/xph-backend-auth
AuthUserFile /data/svn/XPH/auth/passwd
Require valid-user
DAV svn
SVNPath /data/svn/XPH/xph-docs
AuthType Basic
AuthName "Authorization SVN"
AuthzSVNAccessFile /data/svn/XPH/auth/xph-docs-auth
AuthUserFile /data/svn/XPH/auth/passwd
Require valid-user
4、使用htpasswd 创建用户和密码文件
[root@svn ~]# htpasswd -cm /data/svn/XPH/auth/passwd admin
[root@svn ~]# htpasswd -m /data/svn/XPH/auth/passwd art
[root@svn ~]# htpasswd -m /data/svn/XPH/auth/passwd backend
[root@svn ~]# htpasswd -m /data/svn/XPH/auth/passwd docs
[root@svn ~]#
[root@svn ~]# cat /data/svn/XPH/auth/passwd
admin:$apr1$BS1WwAOC$1Tn0dsO6CuJBcZeKYggRO1
art:$apr1$EN6ZlZFo$V8jDvwrM7EdPUSxlg7.LQ0
backend:$apr1$reYSu9TX$20JBLanjsW7k1kh1nDwwJ.
docs:$apr1$y7gnpj3n$FKbgEf8ibF4GV7vlEhq2a/
htpasswd命令是Apache的Web服务器内置工具,用于创建和更新储存用户名、域和用户基本认证的密码文件。
语法
htpasswd (选项) (参数)
选项
-c:创建一个加密文件;
-n:不更新加密文件,只将加密后的用户名密码显示在屏幕上;
-m:默认采用MD5算法对密码进行加密;
-d:采用CRYPT算法对密码进行加密;
-p:不对密码进行进行加密,即明文密码;
-s:采用SHA算法对密码进行加密;
-b:在命令行中一并输入用户名和密码而不是根据提示输入密码;
-D:删除指定的用户。
参数
用户:要创建或者更新密码的用户名;
5、配置apache对SVN目录权限
[root@svn ~]# chown -R apache:apache /data/svn
[root@svn ~]# chmod 755 -R /data/svn
6、修改httpd配置文件
7、启动apache
[root@svn ~]# systemctl start httpd
8、查看端口
[root@svn ~]# systemctl status httpd
[root@svn ~]#
[root@svn ~]# ss -ntlp |grep 80
LISTEN 0 128 :::80 :::* users:(("httpd",pid=21026,fd=4),("httpd",pid=21024,fd=4),("httpd",pid=21023,fd=4),("httpd",pid=21022,fd=4),("httpd",pid=21021,fd=4),("httpd",pid=20987,fd=4))
客户端
一、访问测试
1、浏览器输入IP+项目名称
2、显示Revision 0即表示成功
3、使用svn客户端
4、输入用户和密码
5、
6、客户端提交
7、浏览器查看同步数据
二、用户权限
1、admin管理员用户可以登录所有的项目
2、其他项目只有自己授权的用户才能登录