UbuntuでのApache + Subversion + ViewVC環境構築

サーバを移行したときの作業のメモです。Ubuntu Serverに、ApacheWebDAVでアクセスするSubversionリポジトリを構築して、リポジトリビューアとしてViewVCをインストールします。

apt-getで必要なソフトウェアをインストールします

sudo apt-get install apache2 subversion subversion-tool libapache2-svn

/etc/apache2/mod-available/dav_svn.conf を以下の内容に変更します。

<Location /svn>
  DAV svn
  SVNParentPath /home/svn

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

認証用のパスワードファイルを作成します。"-c"は最初のアカウントのみ。

sudo htpasswd -c /etc/apache2/dav_svn.passwd foo

リポジトリの作成を作成して、Apacheからアクセスできるようにオーナーを変更します。

sudo mkdir /home/svn
sudo svnadmin create /home/svn/repo
sudo chown -R www-data /home/svn

Apacheを再起動します。これで、http://yourserver.com/svn/test/ でrepoリポジトリのアクセスできるはず。

sudo apache2ctl restart

ViewVC

apt-getでインストールします。

sudo apt-get install viewvc

/etc/viewvc/viewvc.conf を開きリポジトリのパスを追加します。

## You can specify multiple parent paths separated by commas or new lines.
##
## WARNING: these names can, of course, clash with names you have
## defined in your cvs_roots or svn_roots configuration items.  If this
## occurs, you can either rename the offending repository on disk, or
## grant new names to the clashing item in cvs_roots or svn_roots.
## Each parent path is processed sequentially, so repositories under
## later parent paths may override earlier ones.
##
## Example:
## root_parents = /opt/svn : svn,
##                /opt/cvs : cvs
##
root_parents = /home/svn : svn ← 追加

/etc/apache2/conf.d/viewvc を作成します。

ScriptAlias /viewvc /usr/lib/cgi-bin/viewvc.cgi

Apacheを再起動してViewVCにアクセスします。

リポジトリの移動

すでにあるリポジトリからデータをコピーします。
移行元のリポジトリのデータをダンプします。

svnadmin dump /path/to/repo > repo.dump

ダンプしたファイルを移行先サーバにコピーして読み込みます。

sudo svnadmin load /path/to/repo < repo.dump