Ground Sunlight

Windowsで作る - PHPプログラミングの開発環境

ユーザ用ツール

サイト用ツール


git2:server:git-web

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

次のリビジョン
前のリビジョン
git2:server:git-web [2020/06/04 23:07]
y2sunlight 作成
git2:server:git-web [2020/06/16 15:28] (現在)
y2sunlight [Apacheの設定]
行 6: 行 6:
 [[git:top|Git に戻る]] [[git:top|Git に戻る]]
  
-本章では、社内用のGitサーバーの構築について説明します。本編の[[git2:server|Smart HTTPによるGitサーバーの構築]]によって、基本的なGitサーバーの機能は得られたので、次は、Webベースのブラウジング機能を追加します。Gitには、GitWebと呼ばれるCGIスクリプトが付属しています。+本章では、社内用のGitサーバーの構築について説明します。本編の[[git2:server|Smart HTTPによるGitサーバーの構築]]によって、基本的なGitサーバーの機能は得られたので、次は、Webベースのブラウジング機能を追加します。Gitには、GitWebと呼ばれるCGIスクリプト(perl5)が付属しているのでこれを利用します。
  
 サーバー環境 サーバー環境
行 16: 行 16:
   * [[git2:server|Gitサーバーの構築 - Gitデーモン/Smart HTTP]]   * [[git2:server|Gitサーバーの構築 - Gitデーモン/Smart HTTP]]
   * Gitサーバーの構築 - Git Web   * Gitサーバーの構築 - Git Web
-  * [[git:client:windows|Git Windowsクライアント]]+  * [[git2:client:windows|Git Windowsクライアント]]
  
 リンク リンク
行 22: 行 22:
   * [[https://git-scm.com/book/ja/v2/Git%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC-%E3%83%97%E3%83%AD%E3%83%88%E3%82%B3%E3%83%AB|Gitサーバー - GitWeb]] --- Pro Git 2'nd Edition(日本語訳)   * [[https://git-scm.com/book/ja/v2/Git%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC-%E3%83%97%E3%83%AD%E3%83%88%E3%82%B3%E3%83%AB|Gitサーバー - GitWeb]] --- Pro Git 2'nd Edition(日本語訳)
   * [[https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb|Git on the Server - GitWeb]] --- Pro Git 2'nd Edition(English)   * [[https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb|Git on the Server - GitWeb]] --- Pro Git 2'nd Edition(English)
 +  * [[https://git-scm.com/docs/gitweb|gitweb - Git web interface]] --- Git Reference
  
 ---- ----
 +
 +===== GitWebのインストール =====
 +
 +gitweb(CGI) を IUSリポジトリからインストールします。本章ではgit2.24を使用しているので、パッケージ名は、''git224-gitweb'' です。Gitのインストールについての詳細は本編の [[centos:yum#iusによるgit2の導入|IUSによるgit2の導入]] をご覧ください。
 +
 +<code>
 +yum install --enablerepo=ius git224-gitweb
 +</code>
 +
 +<div indent>
 +インストールの途中で、インストールしても良いか確認される (''Is this ok [y/d/N]:'') ので ''y'' と回答します。正常にインストールされると最後に、完了のメッセージが表示されます。
 +</div>
 +
 +ここでインストールしたCGI (''gitweb.cgi'') は以下に設置されます。
 +
 +<code>
 +/var/www/git/gitweb.cgi
 +</code>
 +
 +''gitweb.cgi''(Perl5で書かれている) を以下のように編集します。
 +
 +{{fa>folder-open-o}} ** /var/www/git **
 +<code perl gitweb.cgi>
 +...
 +85 # absolute fs-path which will be prepended to the project path
 +86 #our $projectroot = "/pub/scm";
 +87 our $projectroot = "/var/git";
 +...
 +</code>
 +
 +  * 87行目:''$projectroot'' に リポジトリ( 本章では ''/var/git'' )のルートを指定します。
 +\\
 +
 +===== Apacheの設定 =====
 +
 +GitWeb をインストールすると ''/etc/httpd/conf.d/git.conf.rpmnew'' にApacheの設定ファイルの雛形が保存されています。
 +
 +{{fa>folder-open-o}} ** /etc/httpd/conf.d **
 +<code int git.conf.rpmnew>
 +Alias /git /var/www/git
 +
 +<Directory /var/www/git>
 +  Options +ExecCGI
 +  AddHandler cgi-script .cgi
 +  DirectoryIndex gitweb.cgi
 +</Directory>
 +</code>
 +
 +これを参考に「[[git2:server|Gitサーバーの構築 - Gitデーモン/Smart HTTP]]」で設定した [[git2:server#Apacheの設定|git.conf]] を書き直します。
 +
 +{{fa>folder-open-o}} ** /etc/httpd/conf.d **
 +<code int git.conf>
 +# 環境設定
 +SetEnv GIT_PROJECT_ROOT /var/git
 +SetEnv GIT_HTTP_EXPORT_ALL
 +
 +ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
 +
 +# GitWeb
 +Alias /gitweb /var/www/git
 +<Directory /var/www/git>
 +  Options +ExecCGI
 +  AddHandler cgi-script .cgi
 +  DirectoryIndex gitweb.cgi
 +</Directory>
 +
 +# アクセス制御
 +<LocationMatch "^/(git|gitweb)">
 +
 +    <RequireAny>
 +        <RequireAny>
 +            # LAN内の特定のホストのみ許可
 +            Require all denied
 +            Require host localhost
 +            Require ip 127.0.0.1
 +            Require ip 192.168.1.0/24
 +        </RequireAny>
 +
 +        # Basic認証
 +        AuthType Basic
 +        AuthName "Git Access"
 +        AuthUserFile /var/git/.htpasswd
 +        Require valid-user
 +    </RequireAny>
 +
 +    # 全開
 +    # Require all granted
 +
 +</LocationMatch>
 +</code>
 +
 +  * ''/var/www/git'' のエイリアスを ''/gitweb'' に設定します。
 +  * ''/var/www/git'' 下でCGIが動くようにして、''gitweb.cgi'' をインデックスに指定します。
 +  * ''/git'' と ''/gitweb'' の両方で同じアクセス制御ができるように ''LocationMatch'' を変更します。
 +
 +編集が終わったら、Apacheを再起動します。
 +
 +<code>
 +systemctl restart httpd
 +</code>
 +
 +\\
 +
 +===== GitWebへのアクセス =====
 +
 +ブラウザで以下のURLにアクセスして下さい。
 +
 +<code>
 +http://192.168.1.100/gitweb/  # IPアドレスは適宜変更して下さい
 +</code>
 +
 +[{{:git2:server:gitweb01.png?nolink|}}]
 +■ ロポジトリの一覧が表示されます。
 +■ プロジェクト( ここでは ''sandbox.git'' )をクリックして下さい。
 +
 +[{{:git2:server:gitweb02.png?nolink|}}]
 +■ プロジェクトの summary が表示されます。\\ 
 +■ summaryの他に shortlog, log, commit, commitdiff, tree の表示が出来ます
  
 \\ \\
  
git2/server/git-web.1591279634.txt.gz · 最終更新: 2020/06/04 23:07 by y2sunlight