玄箱HGメモ / Debian / SVN+HTTP対応


Last update: 2009-05-14 (木) 15:15:14
実施: 2009/02/10

玄箱HGメモ/Debian/SVN+HTTP対応

緑文字が入力コマンド。


Debian Subversion HTTPアクセス

SubversionをHTTP経由でアクセスできるようにします。
玄箱HGメモ/Debian/Apache2導入にてApache2は導入してあるものとします。

管理者権限(管理者アカウント参照)で作業する必要があります。

libapache2-svn導入

KAGUYA:~# aptitude install libapache2-svn[ENTER]

libapache2-svn導入画面(例)

Reading package lists... Done
Building dependency tree... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
Reading task descriptions... Done
Building tag database... Done
The following NEW packages will be installed:
  libapache2-svn
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 137kB of archives. After unpacking 360kB will be used.
Writing extended state information... Done
Get:1 ftp://ftp.dti.ad.jp stable/main libapache2-svn 1.4.2dfsg1-2 [137kB]
Fetched 137kB in 1m44s (1317B/s)
Selecting previously deselected package libapache2-svn.
(Reading database ... 13361 files and directories currently installed.)
Unpacking libapache2-svn (from .../libapache2-svn_1.4.2dfsg1-2_powerpc.deb) ...
Setting up libapache2-svn (1.4.2dfsg1-2) ...
Enabling dav as a dependency
Module dav installed; run /etc/init.d/apache2 force-reload to enable.
Module dav_svn installed; run /etc/init.d/apache2 force-reload to enable.

KAGUYA:~#

リポジトリ毎の設定

リポジトリの作成

例として/mnt/repos/common/sandboxにリポジトリを作成します。
/mnt/repos/common配下にはsandbox以外のリポジトリを作成する予定です。

HTTP経由で書き込めるようにするためディレクトリの所有者をwww-dataに変えています。
permissionも誰からでも書き込めるように777に変えています。

KAGUYA:~# mkdir /mnt/repos[ENTER]
KAGUYA:~# chown www-data /mnt/repos[ENTER]
KAGUYA:~# chgrp www-data /mnt/repos[ENTER]
KAGUYA:~# chmod 777 /mnt/repos[ENTER]

KAGUYA:~# mkdir /mnt/repos/common[ENTER]
KAGUYA:~# chown www-data /mnt/repos/common[ENTER]
KAGUYA:~# chgrp www-data /mnt/repos/common[ENTER]
KAGUYA:~# chmod 777 /mnt/repos/common[ENTER]

KAGUYA:~# mkdir /mnt/repos/common/sandbox[ENTER]
KAGUYA:~# chown www-data /mnt/repos/common/sandbox[ENTER]
KAGUYA:~# chgrp www-data /mnt/repos/common/sandbox[ENTER]
KAGUYA:~# chmod 777 /mnt/repos/common/sandbox[ENTER]

KAGUYA:~# svnadmin create --fs-type fsfs /mnt/repos/common/sandbox[ENTER]

慣例的なディレクトリ構成を構築しておきます。

KAGUYA:~# svn mkdir file:/mnt/repos/common/sandbox/trunk -m 'setup trunk'[ENTER]
KAGUYA:~# svn mkdir file:/mnt/repos/common/sandbox/branches -m 'setup branches'[ENTER]
KAGUYA:~# svn mkdir file:/mnt/repos/common/sandbox/tags -m 'setup tags'[ENTER]

パスワードファイルの作成

HTTP経由の認証用に/mnt/repos/common/.htpasswdというパスワードファイルを作成します。

SubversionをHTTP経由でアクセスするためのアカウントを追加します。
追加アカウント(例): kanae
追加パスワード(例): -tanimoto-

玄箱/HGのログインアカウントとは全く関係なく作っても問題ありません。

KAGUYA:~# htpasswd -c /mnt/repos/common/.htpasswd kanae[ENTER]

New password: 

表示されないけど-tanimoto-[ENTER]

Re-type new password: 

表示されないけど-tanimoto-[ENTER]

Adding password for user kanae

2回目以降は-cなしで。
KAGUYA:~# htpasswd /mnt/repos/common/.htpasswd yayoi[ENTER]


dav_svn.confの設定

dav_svn.confに上記で作ったリポジトリのLocationを追加します。

元のファイルはとりあえず残しておきます。
KAGUYA:~# cp -p /etc/apache2/mods-available/dav_svn.conf /etc/apache2/mods-available/dav_svn.conf._org[ENTER]

KAGUYA:~# vi /etc/apache2/mods-available/dav_svn.conf[ENTER]

/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 /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
  #AuthzSVNAccessFile /etc/apache2/dav_svn.authz

  # 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 /repos/common>
  DAV svn
  SVNParentPath /mnt/repos/common

  AuthType Basic
  AuthName "Common Subversion Repository"
  AuthUserFile /mnt/repos/common/.htpasswd

  Require valid-user
</Location>

DAV SVN再起動

KAGUYA:~# a2dismod dav_svn[ENTER]

a2dismod dav_svn画面(例)

Module dav_svn disabled; run /etc/init.d/apache2 force-reload to fully disable.

KAGUYA:~# a2enmod dav_svn[ENTER]

a2enmod dav_svn画面(例)

Enabling dav as a dependency
This module is already enabled!
Module dav_svn installed; run /etc/init.d/apache2 force-reload to enable.

Apaceh2再起動

KAGUYA:~# /etc/init.d/apache2 force-reload[ENTER]

Apach2再起動画面(例)

Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.100.100 for ServerName
waiting apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.100.100 for ServerName
.

何かエラーが出てるので玄箱/HGをリブートします。

SVN+HTTP接続確認

HTTP接続

ブラウザで
http://KAGUYA/repos/common/sandbox
のように玄箱/HGのリポジトリを表示します。

ホスト名がだめなら/etc/hostsで指定したIPアドレスで接続します。

正常に繋がるとSubversionをHTTP経由でアクセスするためのアカウントとパスワードを聞いてきます。
アカウント(例): kanae
パスワード(例): -tanimoto-

正常にログインできると以下のような表示が出ます。

リポジトリアクセス画面(例)

  Revision 0: /

  --------------------------------------------------------------------------------
  Powered by Subversion version 1.4.2 (r22196). 

SVN+HTTPで接続できることを確認しました。



コメント

コメントはありません。 コメント/玄箱HGメモ/Debian/SVN+HTTP対応?

Online: 1


FrontPage

Soft

Tips


最新の20件

2021-12-21 2020-04-06 2020-03-10 2013-06-28 2013-11-13 2014-06-24

今日の20件

  • counter: 1283
  • today: 1
  • yesterday: 0
  • online: 1

edit