如何在 GNU/Linux 上设置 Subversion (SVN) 服务器 - Ubuntu

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/60736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 16:24:50  来源:igfitidea点击:

How to set up a Subversion (SVN) server on GNU/Linux - Ubuntu

linuxsvnubuntudebian

提问by Grundlefleck

I have a laptop running Ubuntu that I would like to act as a Subversion server. Both for myself to commit to locally, and for others remotely. What are the steps required to get this working? Please include steps to:

我有一台运行 Ubuntu 的笔记本电脑,我想将其用作 Subversion 服务器。既让我自己在本地承诺,也让其他人远程承诺。使这个工作需要哪些步骤?请包括以下步骤:

  • Get and configure Apache, and necessary modules (I know there are other ways to create a SVN server, but I would like it Apache-specific)
  • Configure a secure way of accessing the server (SSH/HTTPS)
  • Configure a set of authorised users (as in, they must authorised to commit, but are free to browse)
  • Validate the setup with an initial commit (a "Hello world" of sorts)
  • 获取和配置 Apache 以及必要的模块(我知道还有其他方法可以创建 SVN 服务器,但我希望它是特定于 Apache 的)
  • 配置访问服务器的安全方式 (SSH/HTTPS)
  • 配置一组授权用户(例如,他们必须授权才能提交,但可以自由浏览)
  • 使用初始提交验证设置(各种“Hello world”)

These steps can involve any mixture of command line or GUI application instructions. If you can, please note where instructions are specific to a particular distribution or version, and where a users' choice of a particular tool can be used instead (say, nanoinstead of vi).

这些步骤可能涉及命令行或 GUI 应用程序指令的任何混合。如果可以,请注意特定发行版或版本的特定说明,以及可以使用用户选择的特定工具的地方(例如,用nano代替vi)。

采纳答案by Grundlefleck

Steps I've taken to make my laptop a Subversion server. Credit must go to AlephZarrofor his directions here. I now have a working SVN server (which has currently only been tested locally).

我为使我的笔记本电脑成为 Subversion 服务器而采取的步骤。信用必须去AlephZarro对他的指示在这里。我现在有一个可以工作的 SVN 服务器(目前仅在本地进行了测试)。

Specific setup: Kubuntu 8.04 Hardy Heron

具体设置:Kubuntu 8.04 Hardy Heron

Requirements to follow this guide:

遵循本指南的要求:

  • apt-get package manager program
  • text editor (I use kate)
  • sudo access rights
  • apt-get 包管理器程序
  • 文本编辑器(我使用 kate)
  • 须藤访问权限

1: Install Apache HTTP server and required modules:

1:安装Apache HTTP服务器和所需模块:

sudo apt-get install libapache2-svn apache2

The following extra packages will be installed:

将安装以下额外的软件包:

apache2-mpm-worker apache2-utils apache2.2-common

2: Enable SSL

2:启用 SSL

sudo a2enmod ssl
sudo kate /etc/apache2/ports.conf

Add or check that the following is in the file:

添加或检查文件中是否包含以下内容:

<IfModule mod_ssl.c>
    Listen 443
</IfModule>

3: Generate an SSL certificate:

3:生成SSL证书:

sudo apt-get install ssl-cert
sudo mkdir /etc/apache2/ssl
sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem

4: Create virtual host

4:创建虚拟主机

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/svnserver
sudo kate /etc/apache2/sites-available/svnserver

Change (in ports.conf):

更改(在ports.conf 中):

"NameVirtualHost *" to "NameVirtualHost *:443"

and (in svnserver)

和(在 svnserver 中)

<VirtualHost *> to <VirtualHost *:443>

Add, under ServerAdmin (also in file svnserver):

添加,在 ServerAdmin 下(也在文件 svnserver 中):

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM

5: Enable the site:

5:启用站点:

sudo a2ensite svnserver
sudo /etc/init.d/apache2 restart

To overcome warnings:

要克服警告:

sudo kate /etc/apache2/apache2.conf

Add:

添加:

"ServerName $your_server_name"

6: Adding repository(ies): The following setup assumes we want to host multiple repositories. Run this for creating the first repository:

6:添加存储库(IES):以下设置假设我们要托管多个存储库。运行此命令以创建第一个存储库:

sudo mkdir /var/svn

REPOS=myFirstRepo
sudo svnadmin create /var/svn/$REPOS
sudo chown -R www-data:www-data /var/svn/$REPOS
sudo chmod -R g+ws /var/svn/$REPOS

6.a. For more repositories: do step 6 again (changing the value of REPOS), skipping the step mkdir /var/svn

6.a. 对于更多存储库:再次执行第 6 步(更改 REPOS 的值),跳过该步骤mkdir /var/svn

7: Add an authenticated user

7:添加认证用户

sudo htpasswd -c -m /etc/apache2/dav_svn.passwd $user_name

8: Enable and configure WebDAV and SVN:

8:启用和配置WebDAV和SVN:

sudo kate /etc/apache2/mods-available/dav_svn.conf

Add or uncomment:

添加或取消注释:

<Location /svn>
DAV svn

# for multiple repositories - see comments in file
SVNParentPath /var/svn

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL
</Location>

9: Restart apache server:

9:重启apache服务器:

sudo /etc/init.d/apache2 restart

10: Validation:

10:验证:

Fired up a browser:

启动浏览器:

http://localhost/svn/$REPOS
https://localhost/svn/$REPOS

Both required a username and password. I think uncommenting:

两者都需要用户名和密码。我认为取消注释:

<LimitExcept GET PROPFIND OPTIONS REPORT>

</LimitExcept>

in /etc/apache2/mods-available/dav_svn.conf, would allow anonymous browsing.

/etc/apache2/mods-available/dav_svn.conf,将允许匿名浏览。

The browser shows "Revision 0: /"

浏览器显示“修订版 0:/”

Commit something:

提交一些东西:

svn import --username $user_name anyfile.txt https://localhost/svn/$REPOS/anyfile.txt -m “Testing”

Accept the certificate and enter password. Check out what you've just committed:

接受证书并输入密码。查看您刚刚提交的内容:

svn co --username $user_name https://localhost/svn/$REPOS

Following these steps (assuming I haven't made any error copy/pasting), I had a working SVN repository on my laptop.

按照这些步骤(假设我没有进行任何错误复制/粘贴),我的笔记本电脑上有一个可用的 SVN 存储库。

回答by UnkwnTech

For Apache:

对于阿帕奇:

sudo apt-get -yq install apache2

For SSH:

对于 SSH:

sudo apt-get -yq install openssh-server

For Subversion:

对于颠覆:

sudo apt-get -yq install subversion subversion-tools

If you'd like you can combine these into one command like:

如果您愿意,可以将这些组合成一个命令,例如:

sudo apt-get -yq install apache2 openssh-server subversion subversion-tools

I can't help with the rest...

其余的我无能为力...

回答by Kibbee

This articleseems to give a pretty good rundown of the entire process. I would recommend following the instructions, and then posting some more specific questions about any problems you encouter which aren't addressed in the articles I and other people have linked to in these responses.

这篇文章似乎很好地概括了整个过程。我建议您按照说明进行操作,然后针对您遇到的任何问题发布一些更具体的问题,这些问题在我和其他人在这些回复中链接的文章中没有解决。

回答by PuO2

If you get 403 forbidden when you hit the webserver it may be because you used a hostname that is not what you specified in your config file (ie localhost or 127.0.0.1). Try hitting https://whateveryousetasyourhostnameinstead...

如果您在访问网络服务器时收到 403 禁止,这可能是因为您使用的主机名不是您在配置文件中指定的(即 localhost 或 127.0.0.1)。尝试点击https://whateveryousetasyourhostname代替...

回答by Thierry Marianne

Afterwards, I needed to execute (within the context of the example quoted above)

之后,我需要执行(在上面引用的示例的上下文中)

$ sudo chmod g+w /var/svn/$REPOS/db/rep-cache.db

$ sudo chmod g+w /var/svn/$REPOS/db/rep-cache.db

$ sudo chown www-data:www-data /var/svn/$REPOS/db/rep-cache.db

$ sudo chown www-data:www-data /var/svn/$REPOS/db/rep-cache.db

Otherwise I kept receiving a 409 error when committing local modifications (though the commitments were server side effective, I needed to follow up with local updates)

否则,我在提交本地修改时一直收到 409 错误(尽管承诺在服务器端有效,但我需要跟进本地更新)

回答by Ashish Saini

Please write a single command on the terminal.

请在终端上写一个命令。

To open the terminal please press Ctrl+ Alt+ T, and then type this command:

要打开终端,请按Ctrl+ Alt+ T,然后输入以下命令:

$sudo apt-get install subversion