繁体   English   中英

通过 Apache web 服务器和 Ubuntu 上的 DAV 启用 Subversion 访问

[英]enabling Subversion access via Apache web server and DAV on Ubuntu

我有一个 Ubuntu 20 在我的家庭网络上的 PC 上运行,我想在本地网络上用作我家中的 Subversion 服务器。 I have Apache web server installed as well as Subversion installed and I now want to add access through the Apache web server using the HTTP DAV protocol.

我打算在 Windows PC 上使用 Visual Studio 和 Ankh 插件,并在 Ubuntu 服务器上使用 Subversion 来存储我的源代码存储库。

当前修改 Apache 配置以启用使用 HTTP 访问 Subversion 的方法是什么? 到目前为止,我发现的方向似乎对信息有点轻,只不过是一系列要使用的命令,并且由于某种原因它们似乎很旧。

在我看来,由于我支持本地网络上的单个用户,我需要:

  • 创建一个 Subversion 存储库
  • 修改位于文件夹/etc/apache2/mods-enabled中的文件dav_svn.conf
  • 重启 Apache

After doing the above I should be able to access my Subversion repository using the Ankh plug-in for Visual Studio using a URL such as https://192.168.0.4/svn/ , assuming my Ubuntu server is at IP address 192.168.0.4 on我的本地家庭网络。

我目前在哪里:

  • Apache 已安装并运行和服务页面
  • Subversion 与 libapache2-mod-svn 一起安装
  • 我还没有创建 Subversion 存储库

Apache 和 Subversion 的版本是:

rick@rick-MS-7B98:/etc/apache2/mods-enabled$ apache2 -version
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2020-08-12T19:46:17

rick@rick-MS-7B98:/etc/apache2/mods-enabled$ svn --version
svn, version 1.13.0 (r1867053)
   compiled Mar 24 2020, 12:33:36 on x86_64-pc-linux-gnu

我在文件夹/etc/apache2/mods-enabled中找到了一个文件dav_svn.conf ,它似乎是 DAV 通过 Apache 访问 Subversion 的配置文件。 该文件包含:

rick@rick-MS-7B98:/etc/apache2/mods-enabled$ cat dav_svn.conf
# dav_svn.conf - Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.

# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
#<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

  # 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>

The file /etc/apache2/mods-enabled/dav_svn.conf needs to be modified, the Subversion repository created, and the Apache web server restarted in order to allow Subversion repository access through the Apache web server.

首先检查位于/etc/apache2/mods-available中的dav*文件( dav.loaddav_svn.loaddav_svn.conf )的必要符号链接是否位于 / /etc/apache2/mods-enabled目录中当 Apache 启动时,将处理/etc/apache2/mods-enabled中列出的.conf.load文件。

文件dav_svn.conf指定 Apache 服务器需要找到正确目录以及如何执行用户身份验证的 Subversion 存储库的信息。 .load文件指示 Apache 需要加载哪些库才能以编程方式访问存储库。 所需的库位于使用apt installlibapache2-mod-svn package 中。

注意:在尝试删除和清理 Subversion 和 Apache 安装以重新安装它们之后,在处理此问题时,我遇到了aptdpkg错误的问题。 重新安装后使用 Subversion 服务器启动 Apache web 服务器时,请参阅“未知的 DAV 提供程序:svn”,这是我在 askubuntu stackexchange 中发布的一个帖子,目的是寻求帮助。

我使用的dav_svn.conf文件如下:

rick@rick-MS-7B98:/etc/apache2/mods-enabled$ cat dav_svn.conf
# dav_svn.conf - Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.

# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
<Location /svn>

  # Uncomment this to enable the repository
  DAV svn

  # Set this to the path to your repository
  SVNPath /srv/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

  # 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
  Require valid-user

  # 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>

修改文件后,我使用命令sudo systemctl restart apache2重新启动 Apache2 web 服务器,一切都很好。

我必须创建在dav_svn.conf文件的AuthUserFile指令中指定的密码文件/etc/apache2/dav_svn.passwd

我正在使用dav_svn.conf文件的SVNPath指令中指定的/srv/svn的标准 Subversion 存储库路径。 我使用命令sudo svnadmin create /srv/svn创建存储库。

接下来,我使用sudo svn mkdir命令创建了现有 Subversion 存储库( trunkreleasebranches )的目录树,我需要复制这些目录树,以便使用svnadmin load将 Subversion 转储文件加载到我的新存储库中。 请参阅如何导出(然后导入)Subversion 存储库?

安装新的 SSD 以通过 samba 和 webDAV 使用

I wanted to add a new 500GB Samsung SSD to my Ubuntu 20.04 PC for additional file server space to allow sharing of files across my LAN using both samba to allow for a Windows network drive and a webDAV server accessed through the Apache2 web server running on the Ubuntu 电脑。

我做的第一件事是将新的 500GB 三星 EVO 860 SSD 安装到盒子中并启动它。

接下来,我必须为 Linux 格式化驱动器,创建mount点,然后通过在/etc/fstab中添加一个条目来确保它会在 Ubuntu 启动时自动挂载。

我选择的挂载点是/srv/ssda ,要在 samba 和 webDAV 之间共享的文件夹是public文件夹,因此共享区域的路径是/srv/ssda/public 我还决定在 samba 共享Ssda和 webDAV 路径ssdadav ssda

我选择/srv作为根目录而不是/mnt ,因为我已经在/srv中使用文件夹作为 samba 共享。

接下来,我修改了 samba 配置文件/etc/samba/smb.conf以在我之前创建并重新启动 samba 的现有 samba 文件共享下添加新文件夹共享的定义。

[Ssda]
path = /srv/ssda/public
browsable =yes
writable = yes
guest ok = yes
read only = no
create mask = 644

接下来,我修改了 Apache2 配置文件/etc/apache2/sites-enabled/000-default.conf并在现有 webDAV 条目下添加了带有AliasDirectory指令的附加 webDAV 条目,使用的路径与我用于 samba 共享的路径相同。 我重新启动了 Apache。

    Alias /ssdadav /srv/ssda/public

    <Directory /srv/ssda/public>
        DAV On
    </Directory>

此时,我可以坐在 Windows 10 PC 和Map network drive...到新的 SSD 并在那里创建一个简单的文本文件。 Then open up a browser to the Apache server on the Ubuntu PC using a URL of http://192.168.0.4/ssdadav/ and see the text file in the file list and open it in the browser.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM