apache - 在 Ubuntu 上通过 Apache Web 服务器和 DAV 启用 Subversion 访问
问题描述
我有一个 Ubuntu 20 在我的家庭网络上的 PC 上运行,我想在本地网络上用作我家中的 Subversion 服务器。我安装了 Apache Web 服务器和 Subversion,现在我想使用 HTTP DAV 协议通过 Apache Web 服务器添加访问权限。
我打算在 Windows PC 上使用带有 Ankh 插件的 Visual Studio,并在 Ubuntu 服务器上使用 Subversion 来存储我的源代码存储库。
当前修改 Apache 配置以启用使用 HTTP 访问 Subversion 的方法是什么?到目前为止,我发现的方向似乎对信息有点轻,只不过是一系列要使用的命令,并且由于某种原因它们看起来很旧。
在我看来,由于我支持本地网络上的单个用户,我需要:
- 创建一个 Subversion 存储库
- 修改文件
dav_svn.conf
夹中的文件/etc/apache2/mods-enabled
- 重启阿帕奇
https://192.168.0.4/svn/
完成上述操作后,假设我的 Ubuntu 服务器位于192.168.0.4
本地家庭网络上的 IP 地址,我应该能够使用 Visual Studio 的 Ankh 插件使用 URL 访问我的 Subversion 存储库。
我目前在哪里:
- 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>
解决方案
/etc/apache2/mods-enabled/dav_svn.conf
需要修改文件,创建 Subversion 存储库,并重新启动 Apache Web 服务器,以便允许通过 Apache Web 服务器访问 Subversion 存储库。
首先检查位于目录中的dav*
文件(dav.load
、dav_svn.load
和dav_svn.conf
)的必要符号链接/etc/apache2/mods-available
是否在目录中/etc/apache2/mods-enabled
,因为只有.conf
和.load
列出的文件/etc/apache2/mods-enabled
将在 Apache 启动时被处理。
该文件dav_svn.conf
指定有关 Apache 服务器查找正确目录以及如何执行用户身份验证所需的 Subversion 存储库的信息。这些.load
文件指示 Apache 需要加载哪些库才能以编程方式访问存储库。所需的库位于libapache2-mod-svn
随apt install
.
注意:在尝试删除和清理 Subversion 和 Apache 安装以重新安装它们之后,我在处理这个问题时遇到了一个问题apt
和错误。重新安装后使用 Subversion 服务器启动 Apache Web 服务器时,dpkg
请参阅“未知 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 服务器,一切都很好。
我必须创建在文件指令中/etc/apache2/dav_svn.passwd
指定的密码文件。AuthUserFile
dav_svn.conf
我正在使用文件指令中/srv/svn
指定的标准 Subversion 存储库路径。我使用该命令创建存储库。SVNPath
dav_svn.conf
sudo svnadmin create /srv/svn
接下来,我使用该sudo svn mkdir
命令创建了现有 Subversion 存储库(、、和)的目录树trunk
,release
我branches
需要复制这些目录树,以便将svnadmin load
Subversion 转储文件加载到我的新存储库中。请参阅如何导出(然后导入)Subversion 存储库?
安装新的 SSD 以通过 samba 和 webDAV 使用
我想在我的 Ubuntu 20.04 PC 上添加一个新的 500GB 三星 SSD 以获得额外的文件服务器空间,以允许使用 samba 在我的 LAN 上共享文件以允许 Windows 网络驱动器和通过运行在 Apache2 网络服务器上的 webDAV 服务器访问Ubuntu 电脑。
我做的第一件事是将新的 500GB 三星 EVO 860 SSD 安装到盒子中并启动它。
接下来我必须为 Linux 格式化驱动器,创建mount
点,然后通过在/etc/fstab
.
我选择的挂载点是/srv/ssda
,samba 和 webDAV 之间共享的文件夹是一个文件夹public
,所以共享区域的路径是/srv/ssda/public
. 我还决定ssda
在 samba 共享Ssda
和 webDAV 路径的名称中使用ssdadav
.
我选择了/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 条目和附加的 webDAV 条目下添加了Alias
和Directory
指令,使用的路径与我用于 samba 共享的路径相同。我重新启动了 Apache。
Alias /ssdadav /srv/ssda/public
<Directory /srv/ssda/public>
DAV On
</Directory>
此时,我可以坐在 Windows 10 PC 和Map network drive...
新 SSD 上,并在那里创建一个简单的文本文件。然后使用 URL 打开 Ubuntu PC 上的 Apache 服务器的浏览器,http://192.168.0.4/ssdadav/
并在文件列表中查看文本文件并在浏览器中打开它。
推荐阅读
- powershell - Powershell 使用 arg 启动/停止
- javascript - 骨干集合何时真正触发“更新”事件
- java - 我没有数据库选项(Intellij IDEA)
- oracle - 创建oracle函数的问题
- android - 如何在 EditText 中以不同颜色标记值?
- c# - 将鼠标放在 UI 元素上
- java - 如何在从 ArrayList 返回它们之前比较两个对象中保存的变量?
- java - oracleConnection.createARRAY 不适用于 WebLogic 数据源连接
- java - 如果我的数组大小在java中已满,如何动态创建一个新的数组实例
- regex - 正则表达式 - 密码检查 - 热到不能在示例中允许空格