[英]Subversion Access Control using Mysql and Apache (mod-dav-svn, mod-auth-sql, apache, mysql)
[英]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 的方法是什么? 到目前為止,我發現的方向似乎對信息有點輕,只不過是一系列要使用的命令,並且由於某種原因它們似乎很舊。
在我看來,由於我支持本地網絡上的單個用戶,我需要:
/etc/apache2/mods-enabled
中的文件dav_svn.conf
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 的版本是:
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.load
、 dav_svn.load
和dav_svn.conf
)的必要符號鏈接是否位於 / /etc/apache2/mods-enabled
目錄中當 Apache 啟動時,將處理/etc/apache2/mods-enabled
中列出的.conf
和.load
文件。
文件dav_svn.conf
指定 Apache 服務器需要找到正確目錄以及如何執行用戶身份驗證的 Subversion 存儲庫的信息。 .load
文件指示 Apache 需要加載哪些庫才能以編程方式訪問存儲庫。 所需的庫位於使用apt install
的libapache2-mod-svn
package 中。
注意:在嘗試刪除和清理 Subversion 和 Apache 安裝以重新安裝它們之后,在處理此問題時,我遇到了apt
和dpkg
錯誤的問題。 重新安裝后使用 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 存儲庫( trunk
、 release
和branches
)的目錄樹,我需要復制這些目錄樹,以便使用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 條目下添加了帶有Alias
和Directory
指令的附加 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.