服务端安装SVN记录及httpd、nginx实现端口转发域名访问(CentOS7)

目录

一、SVN介绍

二、SVN安装流程

三、详细配置文件

1、vi svnserve.conf 

2、vi authz

3、vi passwd   

4、vi /etc/sysconfig/svnserve

四、客户端测试

1、服务端登录验证

2、端口转发及客户端验证

1)配置httpd转发

2)配置nginx转发

 3、客户端访问


一、SVN介绍

SVN的全称是Subversion,即版本控制系统。作为一个开源的版本控制系统,Subversion管理着随时间改变的数据。这些数据放置在一个中央资料档案库(Repository)中。这个档案库很像一个普通的文件服务器,不过它会记住每一次文件的变动。这样就可以把档案恢复到旧的版本,或是浏览文件的变动历史。Subversion是一个通用的系统,可用来管理任何类型的文件,其中包括程序源码。

二、SVN安装流程

//安装SVN服务端
[root@yang ~]# yum install subversion
[root@yang ~]# cd /opt/
//创建svn版本仓库
[root@yang opt]# mkdir -p svn/repos
[root@yang opt]# cd svn/
[root@yang svn]# chmod -R 777 repos
[root@yang svn]# cd repos/
[root@yang svn]# svnadmin create /opt/svn/repos
[root@yang svn]# cd /opt/svn/repos/
[root@yang repos]# cd conf/
[root@yang conf]# ls
authz  passwd  svnserve.conf
//配置版本库信息,用户文件和用户密码文件的路径,版本库路径
[root@yang conf]# vi svnserve.conf
[root@yang conf]#
[root@yang conf]# vi authz
[root@yang conf]# vi passwd
//设置svn自启动
[root@yang conf]# cat /lib/systemd/system/svnserve.service
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/svnserve
ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS

[Install]
WantedBy=multi-user.target
[root@yang conf]#
[root@yang conf]# vi  /etc/sysconfig/svnserve
[root@yang conf]#
[root@yang conf]#  setenforce 0
setenforce: SELinux is disabled
[root@yang conf]# systemctl enable svnserve.service
Created symlink from /etc/systemd/system/multi-user.target.wants/svnserve.service to /usr/lib/sy                                                                        stemd/system/svnserve.service.
//启动SVN
[root@yang conf]# systemctl start svnserve.service
//启动SVN后测试
[root@yang conf]# netstat -ntlp|grep 3690
tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN      5027/svnserve 

三、详细配置文件

1、vi svnserve.conf 


//配置版本库信息
//这四行,前面的#号和空格去掉
//anon-access改成none,匿名访问的权限,可以是read,write,none,默认为read
anon-access = none
auth-access = write  //使授权用户有写权限
password-db = passwd //密码数据库的路径
//认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字
realm = /opt/svn/repos
//保存退出

2、vi authz


//创建svn组和组用户的权限 
[groups]
 //创建一个组,并制定两个用户
admin = root,yang
//制定根目录下的权限
[/]
//first组用户权限为读写
@admin = rw
//其他用户只有读权限
* = r
//保存退出

3、vi passwd   


//创建或修改用户密码 
[users]
root = 123456
yang = 123456
//保存退出

4、vi /etc/sysconfig/svnserve


//修改svn的service配置文件
OPTIONS="-r /opt/svn/repos"

四、客户端测试

1、服务端登录验证

[root@yang conf]# svn checkout svn://XXX.XXX.XXX.XXX:3690/
Authentication realm: <svn://XXX.XXX.XXX.XXX:3690> svncode
Password for 'root':

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://XXX.XXX.XXX.XXX:3690>  /opt/svn/repos

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
Checked out revision 0.

2、端口转发及客户端验证

1)配置httpd转发

安装httpd,mod_dav_svn

yum install -y httpd mod_dav_svn

 检查Apache,mod_dav_svn是否安装成功

安装成功后,会有mod_dav_svn.so和mod_authz_svn.so两个文件。

[root@yang conf]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 16 2020 16:18:20
[root@yang conf]# find / -name mod_dav_svn.so
/usr/lib64/httpd/modules/mod_dav_svn.so
[root@yang conf]# find / -name mod_authz_svn.so
/usr/lib64/httpd/modules/mod_authz_svn.so

 增加配置文件/etc/httpd/conf.d/subversion.conf

[root@yang conf]# vim /etc/httpd/conf.d/subversion.conf
[root@yang conf]# cat /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
    DAV svn
    SVNParentPath /opt/svn/
    SVNListParentPath On
    AuthType Basic
    AuthName "Authorization SVN"
    AuthzSVNAccessFile /opt/svn/authz
    AuthUserFile /opt/svn/passwd
    Require valid-user
</Location>

 创建用户文件passwd

[root@yang conf]# touch /opt/svn/passwd			
[root@yang conf]# htpasswd /home/data/svn/passwd root
New password: 123456
Re-type new password: 123456
Adding password for user root
[root@yang conf]# 
[root@yang conf]# cat /opt/svn/passwd 
root:$apr1$gQ3qKK9Q$ZYFb.DVPf4vLGzTsU3L0f1

创建权限文件authz

[root@yang conf]# cp /opt/svn/repos/conf/authz /opt/svn/authz
[root@yang conf]# cat /opt/svn/authz

 配置apache对SVN库目录权限

[root@yang conf]# chown -R apache:apache /opt/svn/repos
[root@yang conf]# ll /opt/svn
total 12
-rwxr--r-- 1 root   root   1127 Jul 16 21:04 authz
-rw-r--r-- 1 root   root     43 Jul 16 21:02 passwd
drwxrwxrwx 6 apache apache 4096 Jul 18 04:33 repos

 配置httpd

[root@yang conf]# vim /etc/httpd/conf/httpd.conf

修改 AllowOverride None改为AllowOverride All

启动Apache

[root@yang httpd]# service httpd start

常见httpd命令:

httpd -v          #查看已经安装的httpd的版本
rpm -qa | grep httpd  #查看是否已经安装了httpd
ps -ef | grep httpd   #查看httpd的进程
service httpd status  #查看httpd的运行状态
service httpd stop    #停止httpd
service httpd start   #启动httpd 
service httpd start   #重新启动httpd 

httpd日志路径:  /var/log/httpd/

[root@yang ~]# cd /var/log/httpd/
[root@yang httpd]# ls
access_log  error_log

http登录验证

[root@yang conf]# svn checkout http://xxx.xxx.xxx.xxx/svn/repos/
Authentication realm: <http://xxx.xxx.xxx.xxx:80> Authorization SVN
Password for 'root':

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <http://xxx.xxx.xxx.xxx:80> Authorization SVN

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
Checked out revision 0.

2)配置nginx转发

Nginx之前安装部署过,这里不再重复,只看下配置文件

[root@test conf.d]# cat test.svn.com.conf
server
{
    listen       80;
    listen       [::]:80;
    server_name  test.svn.com;
    include safe.conf;
    access_log  /web/nginx/logs/test.svn.com_access.log  main;

    location / {
        include proxy_params;
        proxy_pass http://xxx.xxx.xxx.xxx:80;
    }
}

浏览器访问

输入用户名密码

 3、客户端访问

客户端下载地址:下载 · TortoiseSVN(https://tortoisesvn.net/downloads.zh.html)

输入用户名密码即可访问


 

Guess you like

Origin blog.csdn.net/xlyrh/article/details/118658273