- 安裝 SVN
- 安裝 Apache
- 整合
- 遇到問題
對于需要使用 SVN的使用者來說,如果想要搭建一個自己的版本控制,SVN相對于GIT 來說簡單很多。
之前寫了一個隻搭建 SVN的教程,連結:Ubuntu學習 - SVN服務搭建
- SVN 的預設端口是:3690 有的伺服器不給開這個端口
- 單獨隻搭建 SVN是無法用網頁打開檢視 SVN項目的。
安裝 SVN
sudo apt-get install subversion
//建立項目目錄
mkdir ~/svn
cd svn/
svnadmin create new_project
cd ../
sudo chown -R www-data:www-data ./svn
安裝 Apache
安裝:
sudo apt-get install apache2
整合
- 安裝子產品
sudo apt-get install libapache2-svn
sudo apt-get install apache2-utils
- 修改配置
sudo vim /etc/apache2/mods-available/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 and SVNParentPath, but not both.
SVNParentPath /home/alps/repository
# 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 /home/alps/repository/slowtech/conf/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>
其中
Location /svn
這裡是要通路的位址字尾。
然後添加一個使用者:
sudo htpasswd ~/svn/new_project/conf/passwd alps
//要求輸入密碼
會在
passwd
的檔案裡生成使用者名和你剛才輸入的密碼
- 重新開機 apache2
sudo apachectl restart
- 打開 http://localhost/svn
遇到問題
<D:error xmlns:D="DAV:" xmlns:m="http://apache.org/dav/xmlns" xmlns:C="svn:">
<C:error/>
<m:human-readable errcode="13">Could not open the requested SVN filesystem</m:human-readable>
</D:error>
這個錯誤首先看配置檔案是否有錯。
然後看檔案夾的權限配置是否有錯。
參考:StackOverflow Ubuntu + SVN: Could not open the requested SVN filesystem