问题
I have an Ubuntu 20 running on a PC on my home network that I want to use as a Subversion server within my house on my local network. 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.
I intend to use Visual Studio with the Ankh plug-in on a Windows PC with the Subversion on the Ubuntu server for storing my source code repository.
What is the current way of modifying the Apache configuration so as to enable accessing Subversion using HTTP? The directions thus far that I have found seem to be a bit light on information, being nothing more than a series of commands to use, and for some reason they appear to be old.
It appears to me that since I'm supporting a single user on a local network, I need to:
- create a Subversion repository
- modify the file
dav_svn.conf
located in the folder/etc/apache2/mods-enabled
- restart 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 my local home network.
Where I currently am:
- Apache is installed and running and serving pages
- Subversion is installed along with libapache2-mod-svn
- I have not yet created a Subversion repository
Versions of Apache and Subversion are:
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
I have found in the folder /etc/apache2/mods-enabled
a file dav_svn.conf
which appears to be a configuration file for DAV access to Subversion through Apache. That file contains:
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>
回答1:
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.
First check that the necessary symbolic links of the dav*
files (dav.load
, dav_svn.load
, and dav_svn.conf
) located in /etc/apache2/mods-available
are in the directory /etc/apache2/mods-enabled
as only the .conf
and .load
files listed in /etc/apache2/mods-enabled
will be processed when Apache starts up.
The file dav_svn.conf
specifies information about the Subversion repository the Apache server needs to find the correct directory and how to perform user authentication. The .load
files instruct Apache as to which libraries need to be loaded to programmatically access the repository. The libraries needed are in the libapache2-mod-svn
package that is installed with apt install
.
Note: while working on this at one point I ran into a problem with apt
and dpkg
errors after I attempted to remove and cleanup both Subversion and Apache installs in order to reinstall them. See “Unknown DAV provider: svn” when starting up Apache web server with Subversion server after reinstall which is a posting in to the askubuntu stackexchange that I did in order to ask for assistance.
The dav_svn.conf
file I am using is as follows:
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>
Once I modified the file I then used the command sudo systemctl restart apache2
to restart the Apache2 web server and things were fine.
I had to create the password file /etc/apache2/dav_svn.passwd
which is specified in the AuthUserFile
directive of the dav_svn.conf
file.
I am using the standard Subversion repository path of /srv/svn
as specified in the SVNPath
directive of the dav_svn.conf
file. I used the command sudo svnadmin create /srv/svn
to create the repository.
Next I used the sudo svn mkdir
command to make the directory tree of an existing Subversion repository (trunk
, release
, and branches
) that I needed to duplicate in order to use svnadmin load
to load a Subversion dump file into my new repository. See How do I export (and then import) a Subversion repository?
来源:https://stackoverflow.com/questions/65241966/enabling-subversion-access-via-apache-web-server-and-dav-on-ubuntu