Debian10: SVN+Apache2安装

先实现SVN通过HTTP协议访问,HTTPS待后。安装步骤如下:

第一步:安装所需软件包

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

第二步:确认相关模块OK

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 service apache2 restart

第三步:修改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 /var/lib/svn
  SVNParentPath /works/svn

  # 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 /etc/apache2/dav_svn.passwd

  # To enable authorization via mod_authz_svn (enable that module separately):
  #<IfModule mod_authz_svn.c>
  #AuthzSVNAccessFile /etc/apache2/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 /works
markul@server:~$ sudo mkdir /svn

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

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

第五步:创建dav_svn.passwd文件

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

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

第六步:重启一下Apache

markul@server:~$ sudo service apache2 restart

第七步:打开浏览器访问

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章