Subversion : HTTP でアクセスする2025/10/08 |
|
[svnserve] を起動せず、HTTP でリポジトリにアクセスできるよう設定します。 |
|
| [1] | |
| [2] | |
| [3] | 必要なパッケージをインストールしておきます。 |
|
root@dlp:~# apt -y install libapache2-mod-svn
|
| [4] | Apache2 の設定です。 例として [/var/svn/repos/project] リポジトリにアクセスできるよう設定します。 |
|
root@dlp:~#
vi /etc/apache2/conf-available/subversion.conf # 新規作成
<Location /project>
DAV svn
AuthType Basic
AuthName "DAV SVN"
AuthUserFile /var/svn/.svnpasswd
Require valid-user
SVNPath /var/svn/repos/project
</Location>
root@dlp:~#
a2enmod dav_svn root@dlp:~# a2enconf subversion root@dlp:~# chown -R www-data:www-data /var/svn/repos/project root@dlp:~# systemctl restart apache2 # ユーザー登録 root@dlp:~# htpasswd -Bc /var/svn/.svnpasswd debian New password: Re-type new password: Adding password for user debian |
| [5] | アクセス権を設定する場合は以下のようにします。 [svnserve] サービス起動時のアクセス権設定とは別の設定です。 |
|
root@dlp:~#
vi /var/svn/repos/project/conf/authzsvn.conf # 新規作成 # グループを定義 [groups] developer = debian,trixie operator = ubuntu # ルートディレクトリのアクセス権は [Read] [/] * = r # [trunk] 配下のアクセス権は [developer] のみ [Read/Write] [project:/trunk] @developer = rw # [branches] 配下のアクセス権は [operator] のみ [Read/Write] [project:/branches] @operator = rw # [tags] 配下のアクセス権は [operator] のみ [Read/Write] [project:/tags] @operator = rw
root@dlp:~#
vi /etc/apache2/conf-available/subversion.conf
<Location /project>
DAV svn
AuthType Basic
AuthName "DAV SVN"
AuthUserFile /var/svn/.svnpasswd
Require valid-user
SVNPath /var/svn/repos/project
# 追記
AuthzSVNAccessFile /var/svn/repos/project/conf/authzsvn.conf
</Location>
root@dlp:~# systemctl reload apache2 |
| [6] | 任意のホストから HTTP/HTTPS アクセスして設定を確認します。 |
|
trixie@node01:~$ svn --username debian list https://dlp.srv.world/project Authentication realm: <https://dlp.srv.world:443> DAV SVN Password for 'debian': ******** branches/ tags/ trunk/
trixie@node01:~$
trixie@node01:~/work$ echo 'store-plaintext-passwords = no' >> ~/.subversion/servers trixie@node01:~$ mkdir work trixie@node01:~$ cd work
svn --username debian co https://dlp.srv.world/project Authentication realm: <https://dlp.srv.world:443> DAV SVN Password for 'debian': ******** A project/branches A project/tags A project/trunk A project/trunk/index.html Checked out revision 4.
trixie@node01:~/work$
cd project/trunk
# 適当にバージョン管理下の任意のファイル編集後に # [ubuntu] ユーザーで [trunk] へ [commit] trixie@node01:~/work/project/trunk$ echo index.html >> index.html trixie@node01:~/work/project/trunk$ svn --username ubuntu ci index.html -m "update by ubuntu"
Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'ubuntu': ********
Sending index.html
Transmitting file data .svn: E195023: Commit failed (details follow):
svn: E195023: Changing file '/home/trixie/work/project/trunk/index.html' is forbidden by the server
svn: E175013: While preparing '/home/trixie/work/project/trunk/index.html' for commit
svn: E175013: Access to '/project/!svn/txr/4-4/trunk/index.html' forbidden
# 設定通り拒否された
# [debian] ユーザーで [trunk] へ [commit] trixie@node01:~/work/project/trunk$ svn --username trixie ci index.html -m "update by trixie"
Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'trixie': ********
Sending index.html
Transmitting file data .done
Committing transaction...
Committed revision 5.
# 設定通り [commit] できた
|
| [7] | HTTP のため Web ブラウザーで参照アクセスすることもできます。 |
|
|
| Sponsored Link |
|
|