当前位置:   article > 正文

服务端安装SVN记录及httpd、nginx实现端口转发域名访问(CentOS7)_svn上传文件后怎么配置nginx访问项目

svn上传文件后怎么配置nginx访问项目

目录

一、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安装流程

  1. //安装SVN服务端
  2. [root@yang ~]# yum install subversion
  3. [root@yang ~]# cd /opt/
  4. //创建svn版本仓库
  5. [root@yang opt]# mkdir -p svn/repos
  6. [root@yang opt]# cd svn/
  7. [root@yang svn]# chmod -R 777 repos
  8. [root@yang svn]# cd repos/
  9. [root@yang svn]# svnadmin create /opt/svn/repos
  10. [root@yang svn]# cd /opt/svn/repos/
  11. [root@yang repos]# cd conf/
  12. [root@yang conf]# ls
  13. authz  passwd  svnserve.conf
  14. //配置版本库信息,用户文件和用户密码文件的路径,版本库路径
  15. [root@yang conf]# vi svnserve.conf
  16. [root@yang conf]#
  17. [root@yang conf]# vi authz
  18. [root@yang conf]# vi passwd
  19. //设置svn自启动
  20. [root@yang conf]# cat /lib/systemd/system/svnserve.service
  21. [Unit]
  22. Description=Subversion protocol daemon
  23. After=syslog.target network.target
  24. [Service]
  25. Type=forking
  26. EnvironmentFile=/etc/sysconfig/svnserve
  27. ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS
  28. [Install]
  29. WantedBy=multi-user.target
  30. [root@yang conf]#
  31. [root@yang conf]# vi /etc/sysconfig/svnserve
  32. [root@yang conf]#
  33. [root@yang conf]# setenforce 0
  34. setenforce: SELinux is disabled
  35. [root@yang conf]# systemctl enable svnserve.service
  36. Created symlink from /etc/systemd/system/multi-user.target.wants/svnserve.service to /usr/lib/sy stemd/system/svnserve.service.
  37. //启动SVN
  38. [root@yang conf]# systemctl start svnserve.service
  39. //启动SVN后测试
  40. [root@yang conf]# netstat -ntlp|grep 3690
  41. 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、服务端登录验证

  1. [root@yang conf]# svn checkout svn://XXX.XXX.XXX.XXX:3690/
  2. Authentication realm: <svn://XXX.XXX.XXX.XXX:3690> svncode
  3. Password for 'root':
  4. -----------------------------------------------------------------------
  5. ATTENTION! Your password for authentication realm:
  6. <svn://XXX.XXX.XXX.XXX:3690> /opt/svn/repos
  7. can only be stored to disk unencrypted! You are advised to configure
  8. your system so that Subversion can store passwords encrypted, if
  9. possible. See the documentation for details.
  10. You can avoid future appearances of this warning by setting the value
  11. of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
  12. '/root/.subversion/servers'.
  13. -----------------------------------------------------------------------
  14. Store password unencrypted (yes/no)? yes
  15. 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两个文件。

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

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

  1. [root@yang conf]# vim /etc/httpd/conf.d/subversion.conf
  2. [root@yang conf]# cat /etc/httpd/conf.d/subversion.conf
  3. LoadModule dav_svn_module modules/mod_dav_svn.so
  4. LoadModule authz_svn_module modules/mod_authz_svn.so
  5. <Location /svn>
  6. DAV svn
  7. SVNParentPath /opt/svn/
  8. SVNListParentPath On
  9. AuthType Basic
  10. AuthName "Authorization SVN"
  11. AuthzSVNAccessFile /opt/svn/authz
  12. AuthUserFile /opt/svn/passwd
  13. Require valid-user
  14. </Location>

 创建用户文件passwd

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

创建权限文件authz

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

 配置apache对SVN库目录权限

  1. [root@yang conf]# chown -R apache:apache /opt/svn/repos
  2. [root@yang conf]# ll /opt/svn
  3. total 12
  4. -rwxr--r-- 1 root root 1127 Jul 16 21:04 authz
  5. -rw-r--r-- 1 root root 43 Jul 16 21:02 passwd
  6. 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/

  1. [root@yang ~]# cd /var/log/httpd/
  2. [root@yang httpd]# ls
  3. access_log error_log

http登录验证

  1. [root@yang conf]# svn checkout http://xxx.xxx.xxx.xxx/svn/repos/
  2. Authentication realm: <http://xxx.xxx.xxx.xxx:80> Authorization SVN
  3. Password for 'root':
  4. -----------------------------------------------------------------------
  5. ATTENTION! Your password for authentication realm:
  6. <http://xxx.xxx.xxx.xxx:80> Authorization SVN
  7. can only be stored to disk unencrypted! You are advised to configure
  8. your system so that Subversion can store passwords encrypted, if
  9. possible. See the documentation for details.
  10. You can avoid future appearances of this warning by setting the value
  11. of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
  12. '/root/.subversion/servers'.
  13. -----------------------------------------------------------------------
  14. Store password unencrypted (yes/no)? yes
  15. Checked out revision 0.

2)配置nginx转发

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

  1. [root@test conf.d]# cat test.svn.com.conf
  2. server
  3. {
  4. listen 80;
  5. listen [::]:80;
  6. server_name test.svn.com;
  7. include safe.conf;
  8. access_log /web/nginx/logs/test.svn.com_access.log main;
  9. location / {
  10. include proxy_params;
  11. proxy_pass http://xxx.xxx.xxx.xxx:80;
  12. }
  13. }

浏览器访问

输入用户名密码

 3、客户端访问

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

输入用户名密码即可访问


 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/909840
推荐阅读
相关标签
  

闽ICP备14008679号