Debian10: SVN+Apache2安装

先实现SVN通过HTTP协议和HTTPS访问,SVN的权限设置另说。
SVN主目录位置为:/disk1/svn/repo,计划创建两个版本仓库:swlib和svntest。

第一步:安装所需软件包

markul@server:~$ sudo apt-get update
markul@server:~$ sudo apt-get install apache2
markul@server:~$ sudo apt-get install subversion libapache2-mod-svn libsvn-dev openssl

第二步:确认相关模块OK,并开启 https

markul@server:~$ sudo a2enmod dav
Module dav already enabled

markul@server:~$ sudo a2enmod dav_svn
Considering dependency dav for dav_svn:
Module dav already enabled
Module dav_svn already enabled

markul@server:~$ sudo a2enmod ssl
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Enabling module socache_shmcb.
Enabling module ssl.
See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
  systemctl restart apache2

markul@server:~$ sudo a2ensite default-ssl
Enabling site default-ssl.
To activate the new configuration, you need to run:
  systemctl reload apache2
markul@server:~$ 

第三步:修改dav_svn.conf

markul@server:~$ sudo vi /etc/apache2/mods-enabled/dav_svn.conf
markul@server:~$ sudo cat /etc/apache2/mods-enabled/dav_svn.conf
<Location /svn>
  # Uncomment this to enable the repository
  DAV svn

  # Set this to the path to your repository
  #SVNPath /var/lib/svn
  # Alternatively, use SVNParentPath if you have multiple repositories under
  # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
  # You need either SVNPath or SVNParentPath, but not both.
  SVNParentPath /disk1/svn/repo
  SVNListParentPath on

  # Access control is done at 3 levels: (1) Apache authentication, via
  # any of several methods.  A "Basic Auth" section is commented out
  # below.  (2) Apache <Limit> and <LimitExcept>, also commented out
  # below.  (3) mod_authz_svn is a svn-specific authorization module
  # which offers fine-grained read/write access control for paths
  # within a repository.  (The first two layers are coarse-grained; you
  # can only enable/disable access to an entire repository.)  Note that
  # mod_authz_svn is noticeably slower than the other two layers, so if
  # you don't need the fine-grained control, don't configure it.

  # Basic Authentication is repository-wide.  It is not secure unless
  # you are using https.  See the 'htpasswd' command to create and
  # manage the password file - and the documentation for the
  # 'auth_basic' and 'authn_file' modules, which you will need for this
  # (enable them with 'a2enmod').
  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /disk1/svn/dav_svn.passwd

  # To enable authorization via mod_authz_svn (enable that module separately):
  #<IfModule mod_authz_svn.c>
  #AuthzSVNAccessFile /disk1/svn/dav_svn.authz
  #</IfModule>

  # The following three lines allow anonymous read, but make
  # committers authenticate themselves.  It requires the 'authz_user'
  # module (enable it with 'a2enmod').
  #<LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
  #</LimitExcept> 

</Location>

第四步:创建仓库

#创建SVN主目录
markul@server:~$ sudo mkdir /disk1/svn
markul@server:~$ sudo mkdir /disk1/svn/repo

#创建swlib项目仓库
markul@server:~$ sudo svnadmin create /disk1/svn/repo/swlib

#创建svntest项目仓库
markul@server:~$ sudo svnadmin create /disk1/svn/repo/svntest

#设置目录权限  注:此路径与dav_svn.conf里的配置一致
markul@server:~$ sudo chown -R www-data:www-data /disk1/svn/repo
markul@server:~$ sudo chmod -R 775 /disk1/svn/repo

第五步:创建dav_svn.passwd文件

#文件名不要错了,注意下划线。 admin为用户名
markul@server:~$ sudo htpasswd -cm /disk1/svn/dav_svn.passwd admin
new password: 
Re-type new password: 
Adding password for user admin

#创建其它用户不用加参数c
markul@server:~$ sudo htpasswd -m /disk1/svn/dav_svn.passwd admin
new password: 
Re-type new password: 
Adding password for user admin

第六步:重启一下Apache

markul@server:~$ sudo service apache2 restart

第七步:打开浏览器访问

 

最后说明:安装过程中省去了证书的安装步骤,使用了系统默认的证书。
证书的路径可以查看文件: /etc/apache2/sites-enabled/default-ssl.conf
生成新的证书后,修改其中的证书路径即可。

SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

 

参考文章:https://tecadmin.net/install-svn-server-on-debian/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值