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/

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