すべてのプロダクト
Search
ドキュメントセンター

Elastic Compute Service:ECS インスタンスでの SVN のデプロイと使用

最終更新日:Aug 22, 2026

Elastic Compute Service (ECS) インスタンスに Subversion (SVN) をデプロイし、HTTP または svnserve アクセスを使用して、チェックアウト、更新、コミットを通じてコードを管理します。

前提条件

ECS インスタンスを作成します。 詳細については、「カスタム起動タブを使用したインスタンスの作成」をご参照ください。

インスタンスは、次の要件を満たす必要があります:

  • インスタンスには、固定パブリック IP アドレスまたは Elastic IP Address (EIP) が必要です。 詳細については、「パブリック帯域幅の有効化」をご参照ください。

  • オペレーティングシステム:Alibaba Cloud Linux 3、Alibaba Cloud Linux 2、または CentOS 7.x。

  • インスタンスタイプ:4 vCPU および 4 GiB 以上のメモリ。 正確な仕様は、プロジェクトのサイズとチームの規模によって異なります。

  • セキュリティグループのインバウンドルールで、ポート 22、80、443 でのトラフィックを許可します。 詳細については、「セキュリティグループルールの追加」をご参照ください。

    説明

    svnserve モードを使用する場合は、ポート 3690 でのトラフィックも許可する必要があります。

説明

このチュートリアルは、SVN のワンクリックデプロイをサポートしています。 ワンクリックで実行

SVN のデプロイ

SVN は、HTTP と svnserve の 2 つのアクセスモードをサポートしています。

特徴

HTTP モード

svnserve モード

プロトコル

HTTP

カスタム SVN プロトコル

アクセス方法

Web ブラウザまたは SVN クライアント

SVN クライアントのみ

ポート

80

3690

セキュリティ

HTTPS 暗号化

デフォルトではプレーンテキスト、暗号化はオプション

設定

Web サーバーの設定

SVN サーバーの設定

機能サポート

権限管理やログ表示など、より多くの機能

より少ない機能

HTTP を使用した SVN のデプロイ

ステップ 1: SVN のインストール

  1. Linux インスタンスに接続します。

    詳細については、「ワークベンチを使用して Linux インスタンスに接続する」をご参照ください。

  2. SVN をインストールします。

    sudo yum install -y subversion
  3. SVN のバージョンを確認します。

    svnserve --version

    以下のような出力が表示された場合、SVN がインストールされていることを示します。

    [ecs-user@iZ2zeczc    ~]$ svnserve --version
    svnserve, version 1.14.1 (r1886195)
       compiled Sep 29 2022

ステップ 2: Apache のインストール

  1. httpd をインストールします。

    sudo yum install httpd -y
  2. httpd のバージョンを確認します。

    httpd -version

    以下のような出力が表示された場合、httpd がインストールされていることを示します。

    [ecs-user@iZ2zeczd    ~]$ httpd -version
    Server version: Apache/2.4.6 (AlibabaCloudLinux)
    Server built:   May 26 2023 16:19:35

ステップ 3: mod_dav_svn のインストール

mod_dav_svn は、SVN リポジトリへの Web アクセスを提供する Apache モジュールです。

mod_dav_svn をインストールします。

sudo yum install mod_dav_svn -y

ステップ 4: SVN の設定

  1. SVN リポジトリを作成します。

    sudo mkdir /var/svn
    cd /var/svn
    sudo svnadmin create /var/svn/svnrepos
  2. SVN リポジトリのユーザーグループを apache に変更します。

    sudo chown -R apache:apache /var/svn/svnrepos
  3. 自動生成されたリポジトリファイルを表示します。

    cd svnrepos
    ls

    次の表に、Subversion のディレクトリについて説明します。

    内容

    説明

    db

    すべてのバージョン管理データファイルを保存します。

    hooks

    フックスクリプトファイルを保存します。

    locks

    リポジトリにアクセスするクライアントを追跡します。

    format

    リポジトリ設定のバージョンを示す整数を含むテキストファイル。

    conf

    アクセスアカウントと権限を含む SVN リポジトリ設定ファイル。

  4. コマンドを実行して、SVN リポジトリのユーザーとパスワードを追加します。

    デフォルトでは、SVN はプレーンテキストパスワードを使用しますが、HTTP ではハッシュ化されたパスワードが必要です。 別の passwd ファイルを生成します。 この例では、ユーザー名が userTest、パスワードが passWDTest のユーザーが追加されます。 次のいずれかのコマンドを実行します:

    • 最初のユーザーを追加するには、-c パラメーターを使用してファイルを作成します。

      sudo htpasswd -c /var/svn/svnrepos/conf/passwd userTest
    • 2 人目以降のユーザーを追加するには、-c を省略します。

      sudo htpasswd /var/svn/svnrepos/conf/passwd userTest

    プロンプトに従ってパスワードを設定します。

  5. conf ディレクトリに移動します。

    cd /var/svn/svnrepos/conf/
  6. アカウントの読み取りおよび書き込み権限を設定します。

    1. アクセス制御ファイルを開きます。

      sudo vim authz
    2. i を押して編集モードに入ります。

    3. ファイルの末尾に次のコードを追加します。 userTest はアカウント、r は読み取り権限、w は書き込み権限です。

      [/]
      userTest=rw
      [aliases]
      # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
      [groups]
      # harry_and_sally = harry,sally
      # harry_sally_and_joe = harry,sally,&joe
      
      # [/foo/bar]
      # harry = rw
      # &joe = r
      # * =
      
      # [repository:/baz/fuz]
      # @harry_and_sally = rw
      # * = r
      
      [/]
      userTest=rw
    4. Esc キーを押し、:wq と入力して Enter キーを押し、保存して終了します。

  7. SVN サービスの設定を変更します。

    1. SVN サービス設定ファイルを開きます。

      sudo vim svnserve.conf
    2. i を押して編集モードに入ります。

    3. 次の行を見つけ、コメント記号 (#) と先頭のスペースを削除します。

      説明

      各行はスペースで始まってはならず、等号 (=) の両側にスペースが必要です。

      anon-access = read
      auth-access = write
      password-db = passwd
      authz-db = authz
      realm = /var/svn/svnrepos
      [general]
      ### The anon-access and auth-access options control access to the
      ### repository for unauthenticated (a.k.a. anonymous) users and
      ### authenticated users, respectively.
      ### Valid values are "write", "read", and "none".
      ### Setting the value to "none" prohibits both reading and writing;
      ### "read" allows read-only access, and "write" allows complete
      ### read/write access to the repository.
      ### The sample settings below are the defaults and specify that anonymous
      ### users have read-only access to the repository, while authenticated
      ### users have read and write access to the repository.
      anon-access = read
      auth-access = write
      ### The password-db option controls the location of the password
      ### database file.  Unless you specify a path starting with a /,
      ### the file's location is relative to the directory containing
      ### this configuration file.
      ### If SASL is enabled (see below), this file will NOT be used.
      ### Uncomment the line below to use the default password file.
      password-db = passwd
      ### The authz-db option controls the location of the authorization
      ### rules for path-based access control.  Unless you specify a path
      ### starting with a /, the file's location is relative to the
      ### directory containing this file.  The specified path may be a
      ### repository relative URL (^/) or an absolute file:// URL to a text
      ### file in a Subversion repository.  If you don't specify an authz-db,
      ### no path-based access control is done.
      ### Uncomment the line below to use the default authorization file.
      authz-db = authz
      ### The groups-db option controls the location of the file with the
      ### group definitions and allows maintaining groups separately from the
      ### authorization rules.  The groups-db file is of the same format as the
      ### authz-db file and should contain a single [groups] section with the
      ### group definitions.  If the option is enabled, the authz-db file cannot
      ### contain a [groups] section.  Unless you specify a path starting with
      ### a /, the file's location is relative to the directory containing this
      ### file.  The specified path may be a repository relative URL (^/) or an
      ### absolute file:// URL to a text file in a Subversion repository.
      ### This option is not being used by default.
      # groups-db = groups
      ### This option specifies the authentication realm of the repository.
      ### If two repositories have the same authentication realm, they should
      ### have the same password database, and vice versa.  The default realm
      ### is repository's uuid.
      realm = /var/svn/svnrepos
      ### The force-username-case option causes svnserve to case-normalize
      ### usernames before comparing them against the authorization rules in the
      ### authz-db file configured above.  Valid values are "upper" (to upper-
    4. Esc キーを押し、:wq と入力して Enter キーを押し、保存して終了します。

  8. SVN リポジトリを起動します。

    このコマンドは、リポジトリの親ディレクトリをルートとして設定するため、クライアントは URL にリポジトリ名を追加することでリポジトリにアクセスできます (例:svn://<EIP>/svnrepos)。

    sudo svnserve -d -r /var/svn/
    説明

    SVN サービスを停止するには、killall svnserve コマンドを実行します。

  9. SVN サービスが起動しているかどうかを確認します。

    ps -ef |grep svn

    以下のような出力が表示された場合、SVN サービスが実行中であることを示します。

    [ecs-user@iZ2zeczdpa5xxx conf]$ ps -ef |grep svn
    ecs-user  2767     1  0 16:50 ?        00:00:00 svnserve -d -r /var/svn/
    ecs-user  2808  2568  1  0 16:50 pts/0    00:00:00 grep --color=auto svn

ステップ 5: Apache の設定

  1. httpd 設定ファイルを作成して編集します。

    sudo vim /etc/httpd/conf.d/subversion.conf
  2. i を押して編集モードに入ります。

  3. subversion.conf ファイルに次の設定を入力します。

    <Location /svn>
    DAV svn
    SVNParentPath /var/svn
    AuthType Basic
    AuthName "Authorization SVN"
    AuthzSVNAccessFile /var/svn/svnrepos/conf/authz
    AuthUserFile /var/svn/svnrepos/conf/passwd
    Require valid-user
    </Location>
  4. Esc キーを押し、:wq と入力して Enter キーを押し、保存して終了します。

  5. Apache サービスを起動します。

    sudo systemctl start httpd.service

svnserve を使用した SVN のデプロイ

ステップ 1: SVN のインストール

  1. Linux インスタンスに接続します。

    詳細については、「ワークベンチを使用して Linux インスタンスに接続する」をご参照ください。

  2. SVN をインストールします。

    sudo yum install -y subversion
  3. SVN のバージョンを確認します。

    svnserve --version

    以下のような出力が表示された場合、SVN がインストールされていることを示します。

    [ecs-user@iZ2zeczc    ~]$ svnserve --version
    svnserve, version 1.14.1 (r1886195)
       compiled Sep 29 2022

ステップ 2: SVN の設定

  1. SVN リポジトリを作成します。

    sudo mkdir /var/svn
    cd /var/svn
    sudo svnadmin create /var/svn/svnrepos
  2. 自動生成されたリポジトリファイルを表示します。

    cd svnrepos
    ls

    次の表に、Subversion のディレクトリについて説明します。

    内容

    説明

    db

    すべてのバージョン管理データファイルを保存します。

    hooks

    フックスクリプトファイルを保存します。

    locks

    リポジトリにアクセスするクライアントを追跡します。

    format

    リポジトリ設定のバージョンを示す整数を含むテキストファイル。

    conf

    アクセスアカウントと権限を含む SVN リポジトリ設定ファイル。

  3. SVN リポジトリのユーザー名とパスワードを設定します。

    1. ユーザー設定ファイルを開きます。

      cd conf/
      sudo vim passwd
    2. i を押して編集モードに入ります。

    3. [users] セクションに移動し、ユーザー名とパスワードを追加します。

      説明

      フォーマット:username = password。 例:userTest = passWDTest (下記参照)。 等号 (=) の両側にスペースが必要です。

      ### This file is an example password file for svnserve.
      ### Its format is similar to that of svnserve.conf. As shown in the
      ### example below it contains one section labelled [users].
      ### The name and password for each user follow, one account per line.
      
      [users]
      # harry = harrysecret
      # sally = sallyssecret
      userTest = passWDTest
    4. Esc キーを押し、:wq と入力して Enter キーを押し、保存して終了します。

  4. アカウントの読み取りおよび書き込み権限を設定します。

    1. アクセス制御ファイルを開きます。

      sudo vim authz
    2. i を押して編集モードに入ります。

    3. ファイルの末尾に次のコードを追加します。 userTest はアカウント、r は読み取り権限、w は書き込み権限です。

      [/]
      userTest=rw
      [aliases]
      # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
      [groups]
      # harry_and_sally = harry,sally
      # harry_sally_and_joe = harry,sally,&joe
      
      # [/foo/bar]
      # harry = rw
      # &joe = r
      # * =
      
      # [repository:/baz/fuz]
      # @harry_and_sally = rw
      # * = r
      
      [/]
      userTest=rw
    4. Esc キーを押し、:wq と入力して Enter キーを押し、保存して終了します。

  5. SVN サービスの設定を変更します。

    1. SVN サービス設定ファイルを開きます。

      sudo vim svnserve.conf
    2. i を押して編集モードに入ります。

    3. 次の行を見つけ、コメント記号 (#) と先頭のスペースを削除します。

      説明

      各行はスペースで始まってはならず、等号 (=) の両側にスペースが必要です。

      anon-access = read
      auth-access = write
      password-db = passwd
      authz-db = authz
      realm = /var/svn/svnrepos
      [general]
      ### The anon-access and auth-access options control access to the
      ### repository for unauthenticated (a.k.a. anonymous) users and
      ### authenticated users, respectively.
      ### Valid values are "write", "read", and "none".
      ### Setting the value to "none" prohibits both reading and writing;
      ### "read" allows read-only access, and "write" allows complete
      ### read/write access to the repository.
      ### The sample settings below are the defaults and specify that anonymous
      ### users have read-only access to the repository, while authenticated
      ### users have read and write access to the repository.
      anon-access = read
      auth-access = write
      ### The password-db option controls the location of the password
      ### database file.  Unless you specify a path starting with a /,
      ### the file's location is relative to the directory containing
      ### this configuration file.
      ### If SASL is enabled (see below), this file will NOT be used.
      ### Uncomment the line below to use the default password file.
      password-db = passwd
      ### The authz-db option controls the location of the authorization
      ### rules for path-based access control.  Unless you specify a path
      ### starting with a /, the file's location is relative to the
      ### directory containing this file.  The specified path may be a
      ### repository relative URL (^/) or an absolute file:// URL to a text
      ### file in a Subversion repository.  If you don't specify an authz-db,
      ### no path-based access control is done.
      ### Uncomment the line below to use the default authorization file.
      authz-db = authz
      ### The groups-db option controls the location of the file with the
      ### group definitions and allows maintaining groups separately from the
      ### authorization rules.  The groups-db file is of the same format as the
      ### authz-db file and should contain a single [groups] section with the
      ### group definitions.  If the option is enabled, the authz-db file cannot
      ### contain a [groups] section.  Unless you specify a path starting with
      ### a /, the file's location is relative to the directory containing this
      ### file.  The specified path may be a repository relative URL (^/) or an
      ### absolute file:// URL to a text file in a Subversion repository.
      ### This option is not being used by default.
      # groups-db = groups
      ### This option specifies the authentication realm of the repository.
      ### If two repositories have the same authentication realm, they should
      ### have the same password database, and vice versa.  The default realm
      ### is repository's uuid.
      realm = /var/svn/svnrepos
      ### The force-username-case option causes svnserve to case-normalize
      ### usernames before comparing them against the authorization rules in the
      ### authz-db file configured above.  Valid values are "upper" (to upper-
    4. Esc キーを押し、:wq と入力して Enter キーを押し、保存して終了します。

  6. SVN リポジトリを起動します。

    このコマンドは、リポジトリの親ディレクトリをルートとして設定するため、クライアントは URL にリポジトリ名を追加することでリポジトリにアクセスできます (例:svn://<EIP>/svnrepos)。

    sudo svnserve -d -r /var/svn/
    説明

    SVN サービスを停止するには、killall svnserve コマンドを実行します。

  7. SVN サービスが起動しているかどうかを確認します。

    ps -ef |grep svn

    以下のような出力が表示された場合、SVN サービスが実行中であることを示します。

    [ecs-user@iZ2zeczdpa5xxx conf]$ ps -ef |grep svn
    ecs-user  2767     1  0 16:50 ?        00:00:00 svnserve -d -r /var/svn/
    ecs-user  2808  2568  1  0 16:50 pts/0    00:00:00 grep --color=auto svn

SVN の使用

一般的な SVN コード管理のワークフローは次のとおりです:

  1. チェックアウト:ソースコードをローカルコンピューターにチェックアウトします。

  2. 他のユーザーがソースコードを変更し、リポジトリにコミットします。

  3. 更新:最新のコードを取得します。

  4. ソースコードを変更し、デバッグします。

  5. コミット:変更したコードをリポジトリにコミットします。 これにより、他のプログラマーが変更内容を確認できるようになります。

ソースコードをローカルディレクトリにチェックアウトする (チェックアウト)

  1. ローカルの Windows コンピューターに TortoiseSVN クライアントをダウンロードしてインストールします。

  2. ローカルプロジェクトフォルダーの空白領域を右クリックします。

    この例では、フォルダーは C:\Test です。

  3. ポップアップメニューで [SVN Checkout...] を選択します。

  4. 次の情報を入力し、[OK] をクリックします:

    • [URL of repository]:ソースコードが保存されている URL。

      • HTTP アクセスモード:URL は http://<ECS インスタンスのパブリック IP アドレス>/svn/<SVN リポジトリ名> の形式です。

      • svnserve アクセスモード:URL は svn://<インスタンスのパブリック IP アドレス>/<SVN リポジトリ名> の形式です。

        説明

        SVN サービスがリポジトリの親ディレクトリで起動された場合は、SVN チェックアウト URL にリポジトリ名を追加します。

    • [Checkout directory]:ソースコードのローカルディレクトリ。 この例では、C:\Test です。

    説明

    初回ログイン時に、[passwd] ファイルで設定したユーザー名とパスワードを入力します。

    チェックアウトが完了すると、[Checkout Finished!] ダイアログボックスが表示され、[At revision: 0] と表示されます。これは、ソースコードが正常にチェックアウトされたことを示します。

更新の取得 (Update)

サーバー側リポジトリが更新された後、ローカルプロジェクトフォルダーの空白領域を右クリックし、[SVN Update] を選択して最新バージョンをダウンロードします。

説明

SVN Update は、プロジェクトフォルダー内の既存のコンテンツを上書きします。 更新する前にプロジェクトをバックアップしてください。

変更のコミット (Commit)

ローカルの変更をサーバー側リポジトリにコミットします:

  1. プロジェクトファイルの空白領域を右クリックし、[SVN Commit...] を選択します。

  2. バージョン更新のコメントを入力し、コミットするコンテンツを選択して、[OK] をクリックします。

    ローカルプロジェクトがリポジトリプロジェクトを上書きします。

    説明
    • 2 人のユーザーが変更をコミットした場合、バージョンが古いため、後のコミットは失敗します。 プロジェクトをバックアップし、サーバーから最新バージョンをダウンロードし、ローカルフォルダーをご自身の変更で上書きしてから、[SVN Commit] をクリックしてください。

    • コミットされたプロジェクト内のファイルを削除すると、次のようなメッセージが表示されます。 [Commit] ダイアログボックスで、[Message] エリアにコミットメッセージを入力します。 [Changes made] エリアには、コミットするファイルとそのステータスが一覧表示されます (例:ステータスが [missing] の test1.txt は、ファイルが作業コピーから削除されたことを示します)。 [OK] をクリックしてコミットします。

ファイルの復元

SVN で削除されたファイルを復元します:

  1. ローカルプロジェクトフォルダーを開き、右クリックして [SVN Checkout]... を選択し、データをチェックアウトします。

  2. ファイルの 1 つを削除します。

  3. 変更をコミットしたかどうかに基づいて、適切な操作を選択します:

    • まだコミットしていない場合は、空白領域を右クリックし、[TortoiseSVN] > [Revert...] を選択します。

    • すでにコミットしている場合、サーバー側リポジトリが同期され、そこでもファイルが削除されます。 次の手順で元に戻します:

      1. 空白領域を右クリックし、[TortoiseSVN] > [Show log] を選択します。

      2. 削除のログエントリをクリックします。 削除されたデータが下に表示されます。

        [Changed Paths] エリアには、削除されたファイルのパス (例:/test2.txt) と操作タイプ [Deleted] が表示されます。

      3. 削除されたデータを右クリックし、[Save revision to...] をクリックします。

      4. ファイル名を設定し、[Save] をクリックしてファイルを元の場所に復元します。 保存ダイアログボックスで、保存パス (例:C:\Test) を選択し、ファイル名フィールドに [test2.txt] と入力して、[Save] をクリックします。

  4. 元のフォルダーを開き、[SVN Commit...] をクリックしてリポジトリと同期します。

よくある質問

TortoiseSVN を使用して SVN サーバーにアクセスすると、「ホストが応答しませんでした」というプロンプトが表示されるのはなぜですか?

考えられる原因:

  • SVN サーバーが起動していない。

  • 必要なポートがセキュリティグループで開かれていない。

  • firewalld ファイアウォールが有効になっているが、必要なポートが許可されていない。

次のようにトラブルシューティングを行ってください:

  1. SVN サービスの状態を確認します。

    ps -ef |grep svn

    出力に svnserve プロセスが含まれている場合、SVN サービスは実行中です。 含まれていない場合は、sudo svnserve -d -r /var/svn/ を実行して起動します。

  2. セキュリティグループルールが SVN サーバーの要件を満たしているかどうかを確認します。

    1. HTTP モード:ポート 22、80、443。

    2. svnserve モード:ポート 22、80、443、3690。

  3. firewalld ファイアウォールを確認します。

    1. firewalld の状態を確認します。

      sudo firewall-cmd --state 
      • not running が返された場合、ファイアウォールは無効になっており、SVN には影響しません。

      • running が返された場合、ファイアウォールは有効です。 次のステップに進んでください。

    2. 必要な SVN ポート (ポート 3690 など) でのトラフィックを許可します。

      sudo firewall-cmd --add-port=3690/tcp --permanent
    3. firewalld の設定をリロードします。

      sudo systemct