当前位置: 首页 > backend >正文

Linux 安装subversion+mod_dav_svn,搭建subversion(svn)服务器

目录

  • 前言
  • 通过yum源安装subversion 和 mod_dav_svn
    • 检查subversion是否安装成功
    • 检查apache是否安装成功
    • apache无法启动错误:Address already in use
  • 配置mod_dav_svn
    • 新增 subversion.conf.inc 文件
    • 新增 VirtualHost
    • htpasswd 文件
    • 新增 authz.conf 文件
    • apache reload
    • 新建SVN仓库
    • 访问
    • 关于 Satisfy
  • 排错
    • svn commit 错误:could not begin a transaction
    • Could not open the requested SVN filesystem [500, #125006]
  • 参考

前言

  • OS: CentOS Linux release 7.9.2009 (Core)

通过yum源安装subversion 和 mod_dav_svn

shell> yum install subversion
shell> yum install mod_dav_svn
  • 通过yum源安装的subversion,既包含服务端,又包含客户端。
  • 通过yum源安装的mod_dav_svn,是个带了mod_dav、mod_dav_svn、mod_authz_svn的apache。

检查subversion是否安装成功

shell> svn --version
svn, version 1.10.2 (r1835932)compiled Feb 22 2021, 05:02:40 on x86_64-redhat-linux-gnuCopyright (C) 2018 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 access (RA) modules are available:* ra_svn : Module for accessing a repository using the svn network protocol.- with Cyrus SASL authentication- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.- handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.- using serf 1.3.9 (compiled with 1.3.9)- handles 'http' scheme- handles 'https' schemeThe following authentication credential caches are available:* Plaintext cache in /root/.subversion
* Gnome Keyring
* GPG-Agent

检查apache是否安装成功

尝试启动apache,如果能够启动成功,就表示apache安装成功。

  1. 查看apache版本
shell> httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Mar 24 2022 14:57:57
  1. 启动 apache
shell> systemctl start httpd
  1. 查看 apache 的运行状态,其状态为Active: active (running)时,表示apache已启动成功。
shell> systemctl status httpd
● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)Active: active (running) since Sun 2022-09-04 10:55:17 CST; 1s agoDocs: man:httpd(8)man:apachectl(8)Main PID: 25818 (httpd)Status: "Processing requests..."Tasks: 6Memory: 3.0MCGroup: /system.slice/httpd.service├─25818 /usr/sbin/httpd -DFOREGROUND├─25819 /usr/sbin/httpd -DFOREGROUND├─25820 /usr/sbin/httpd -DFOREGROUND├─25821 /usr/sbin/httpd -DFOREGROUND├─25822 /usr/sbin/httpd -DFOREGROUND└─25823 /usr/sbin/httpd -DFOREGROUNDSep 04 10:55:17 tencent-test-02 systemd[1]: Starting The Apache HTTP Server...
Sep 04 10:55:17 tencent-test-02 httpd[25818]: AH00558: httpd: Could not reliably determine the server's fully q...ssage
Sep 04 10:55:17 tencent-test-02 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
  1. 还可以通过浏览器访问 apache,查看其提供的默认网页
    在这里插入图片描述
    注意:不同版本的apache提供的默认网页是不一样的。

apache无法启动错误:Address already in use

apache无法启动,查看日志,发现错误为Address already in use

shell> systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.shell> systemctl status httpd.service
● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)Active: failed (Result: exit-code) since Sun 2022-09-04 10:57:01 CST; 1min 6s agoDocs: man:httpd(8)man:apachectl(8)Process: 26171 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)Main PID: 26171 (code=exited, status=1/FAILURE)Sep 04 10:57:01 tencent-test-02 systemd[1]: Starting The Apache HTTP Server...
Sep 04 10:57:01 tencent-test-02 httpd[26171]: AH00558: httpd: Could not reliably determine the server's fully q...ssage
Sep 04 10:57:01 tencent-test-02 httpd[26171]: (98)Address already in use: AH00072: make_sock: could not bind to...:]:80
Sep 04 10:57:01 tencent-test-02 httpd[26171]: (98)Address already in use: AH00072: make_sock: could not bind to....0:80
Sep 04 10:57:01 tencent-test-02 httpd[26171]: no listening sockets available, shutting down
Sep 04 10:57:01 tencent-test-02 httpd[26171]: AH00015: Unable to open logs
Sep 04 10:57:01 tencent-test-02 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Sep 04 10:57:01 tencent-test-02 systemd[1]: Failed to start The Apache HTTP Server.
Sep 04 10:57:01 tencent-test-02 systemd[1]: Unit httpd.service entered failed state.
Sep 04 10:57:01 tencent-test-02 systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

错误为Address already in use时,有两个解决办法:

  • 方法1:找到占用80端口的程序,kill掉该程序,然后再启动apache即可。
  • 方法2:更换个端口(不用80端口了)。

配置mod_dav_svn

能看懂英文的,参考这里:

  • https://svnbook.red-bean.com/en/1.1/ch06s04.html
  • https://svnbook.red-bean.com/en/1.7/svn.serverconfig.httpd.html

新增 subversion.conf.inc 文件

/etc/httpd/conf.d 目录下,新增 subversion.conf.inc 文件:

shell> cd /etc/httpd/conf.d
shell> vim subversion.conf.inc

subversion.conf.inc 文件内容:

# 所有请求都要求先登录
<Location /># 认证类型为基本认证# 认证类型为基本认证时,未登录的情况下,将在浏览器中弹出一个认证(登录)对话框。AuthType Basic# 认证名称。 认证对话框的标题# 在认证对话框中输入用户名和密码AuthName "Subversion Repository"# 认证功能使用的、保持用户名和密码的文件AuthUserFile /home/svn/htpasswd# 要求验证用户(即:不能匿名访问)Require valid-user
</Location>
# svn 配置
<Location /svn/>DAV svn # 如果只有一个SVN仓库,使用该选项# SVNPath /absolute/path/to/repository# 如果有多个SVN仓库,使用该选项SVNParentPath /home/svn# 打开这个选项可以列出ParentPath下面的所有库。取值: on/offSVNListParentPath off# 所有仓库共用一个访问权限配置文件AuthzSVNAccessFile /home/svn/authz.conf# 每个仓库一个访问权限配置文件。仓库目录/conf/authz.conf# AuthzSVNReposRelativeAccessFile authz.conf
</Location>
  • 从 Subversion 1.7 开始, 还可以用 配置指令 AuthzSVNReposRelativeAccessFile 指定 每个仓库各自的访问权限配置文件.

新增 VirtualHost

/etc/httpd/conf.d 目录下,新增 subversion_vhost.conf 文件:

shell> cd /etc/httpd/conf.d
shell> vim subversion_vhost.conf

不启用HTTPS时,subversion_vhost.conf 文件内容:

<VirtualHost xxx.xxx.xxx.xxx:80>DocumentRoot "/var/www/empty/html_ssl"ServerName xxx.xxx.com<LocationMatch ".*">ErrorDocument 403 "<H1>403</H1><p>https</p>"ErrorDocument 404 "<H1>404</H1><p>https</p>"RewriteEngine OnRewriteRule "/svn" "-" [END]RewriteRule "/svn/.*" "-" [END]RewriteRule ".*" "-" [R=404]</LocationMatch>Include conf.d/subversion.conf.inc
</VirtualHost>

启用HTTPS时,subversion_vhost.conf 文件内容:

<VirtualHost xxx.xxx.xxx.xxx:443>DocumentRoot "/var/www/empty/html_ssl"ServerName xxx.xxx.comSSLEngine onSSLCertificateFile /etc/httpd/cert.d/com.xxx.xxx.certSSLCertificateKeyFile /etc/httpd/cert.d/com.xxx.xxx.keySSLCertificateChainFile /etc/httpd/cert.d/cacert.pem<LocationMatch ".*">ErrorDocument 403 "<H1>403</H1><p>https</p>"ErrorDocument 404 "<H1>404</H1><p>https</p>"RewriteEngine OnRewriteRule "/svn" "-" [END]RewriteRule "/svn/.*" "-" [END]RewriteRule ".*" "-" [R=404]</LocationMatch>Include conf.d/subversion.conf.inc
</VirtualHost>
  • 443端口为https

htpasswd 文件

已存在htpasswd 文件,增加用户:

shell> htpasswd -m /home/svn/htpasswd rose
New password: *******
Re-type new password: *******
Adding password for user rose
  • htpasswd 命令中使用 -m 选项时,使用 MD5 加密密码。
  • subversion.passwd文件不存在时, htpasswd 命令中添加 -c 选项会创建文件。

修改密码:

shell> htpasswd -m /home/svn/htpasswd jack
New password: ***** 
Re-type new password: *****
Adding password for user jack

删除用户:

shell> htpasswd -D /home/svn/htpasswd jack

新增 authz.conf 文件

参考这里:https://svnbook.red-bean.com/en/1.7/svn.serverconfig.pathbasedauthz.html

/home/svn/ 目录下,新增 authz.conf 文件:

shell> cd /home/svn
shell> vim authz.conf  

authz 文件内容:

[test:/]
rose=r
jack=rw

名为test的svn仓库,rose有read权限,jack有read和write权限。

apache reload

shell> systemctl reload httpd 

新建SVN仓库

shell> svnadmin create /home/svn/test
shell> chown -R apache /home/svn/test
  • 修改/home/svn/test目录的所有者为apache

访问

在这里插入图片描述

在这里插入图片描述
修改subversion.authz 文件内容:

[test:/]
rose=
jack=rw

apache reload后,再次访问如下图
在这里插入图片描述

关于 Satisfy

如果不想让用户匿名访问svn仓库,就不要加这个选项了。
参考:

  • https://blog.csdn.net/weixin_34268169/article/details/92600408
  • https://cloud.tencent.com/developer/ask/sof/53801

排错

svn commit 错误:could not begin a transaction

发生错误could not begin a transaction,是因为 apache 没有svn仓库所在目录的权限。
修改 apache 帐号的权限:

shell> chown -R apache /home/svn/test

Could not open the requested SVN filesystem [500, #125006]

迁移svn数据到另一台服务器时遇到。
源服务器上subversion版本v1.10.7,目标服务器上subversion版本v1.7.14。
将目标服务器上subversion升级至v1.10.7得到解决。

参考

  • https://subversion.apache.org/packages.html
  • 《Subversion 与版本控制》 在线阅读:https://svnbook.red-bean.com/
  • Subversion 1.7 : https://svnbook.red-bean.com/en/1.7/index.html
  • Subversion 1.8 : https://svnbook.red-bean.com/nightly/zh/index.html
http://www.xdnf.cn/news/11353.html

相关文章:

  • JAVA多态(超详细讲解)
  • Activiti 工作流引擎 详解
  • Linux 内核编译 modules ehci-hcd, ohci-hcd, uhci-hcd not found
  • springboot接口文档
  • E - Shooting Game FZU - 2144
  • 【CBAP50技术手册】#34 Process Analysis(流程分析):业务分析师的“优化镜头”
  • inno setup介绍
  • KMP算法精讲
  • 电脑联网跳msftconnecttest(无论是不是校园网)
  • Genymotion中文手册,Genymotion配置
  • 在ubuntu下安装mysql
  • 如何快速绘制一张业务流程图?8张实操案例帮你快速上手!
  • 自动跳转到www.0749.com网页问题
  • Java IDEA JUnit 单元测试
  • XMLHttpRequest的五种状态描述——常见的请求头和相应头都有什么——reflow(回流)repaint(重绘)引起变换的原因
  • 转:LaTeX 换行换页与段落命令与图书模板
  • InstallShield使用完全教程
  • ADB安装及使用详解(非常详细)从零基础入门到精通,看完这一篇就够了
  • 多个域名可以指向同一个主机ip地址_一文彻底搞懂外贸网站相关的域名设置
  • IMP ORA-20005: object statistics are locked(二)
  • WAP页上传图片
  • 15个Python兼职接单平台!利用业余时间赚钱
  • 捷克论坛新ip_兰峰:提升哈尔滨冰雪文化IP打造能力
  • emule最新服务器地址,emule 国内服务器(最新emule服务器)
  • 提升C# 写入Excel操作的效率方式
  • LoadRunner压力测试方法
  • 高分卫星系列介绍及其传感器参数
  • MySQL基础入门教程(非常详细)从零基础入门到精通,看完这一篇就够了
  • 操作系统——缓冲区(buffer)与缓存(cache)
  • scrum回顾_敏捷,Scrum框架入门一篇文章就够了