Windowsで作る - PHPプログラミングの開発環境
このページへのアクセス 今日: 0 / 昨日: 2 総計: 4758
Git 2.24
— y2sunlight 2020-06-04
Git に戻る
本章では、社内用のGitサーバーの構築について説明します。本編の「Smart HTTPによるGitサーバーの構築」によって、基本的なGitサーバーの機能は得られたので、次は、Webベースのブラウジング機能を追加します。Gitには、GitWebと呼ばれるCGIスクリプト(perl5)が付属しているのでこれを利用します。
サーバー環境
関連記事
リンク
gitweb(CGI) を IUSリポジトリからインストールします。本章ではgit2.24を使用しているので、パッケージ名は、git224-gitweb です。Gitのインストールについての詳細は本編の IUSによるgit2の導入 をご覧ください。
git224-gitweb
yum install --enablerepo=ius git224-gitweb
インストールの途中で、インストールしても良いか確認される (Is this ok [y/d/N]:) ので y と回答します。正常にインストールされると最後に、完了のメッセージが表示されます。
Is this ok [y/d/N]:
y
ここでインストールしたCGI (gitweb.cgi) は以下に設置されます。
gitweb.cgi
/var/www/git/gitweb.cgi
gitweb.cgi(Perl5で書かれている) を以下のように編集します。
** /var/www/git **
... 85 # absolute fs-path which will be prepended to the project path 86 #our $projectroot = "/pub/scm"; 87 our $projectroot = "/var/git"; ...
$projectroot
/var/git
GitWeb をインストールすると /etc/httpd/conf.d/git.conf.rpmnew にApacheの設定ファイルの雛形が保存されています。
/etc/httpd/conf.d/git.conf.rpmnew
** /etc/httpd/conf.d **
Alias /git /var/www/git <Directory /var/www/git> Options +ExecCGI AddHandler cgi-script .cgi DirectoryIndex gitweb.cgi </Directory>
これを参考に「Gitサーバーの構築 - Gitデーモン/Smart HTTP」で設定した 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>
/var/www/git
/gitweb
/git
LocationMatch
編集が終わったら、Apacheを再起動します。
systemctl restart httpd
ブラウザで以下のURLにアクセスして下さい。
http://192.168.1.100/gitweb/ # IPアドレスは適宜変更して下さい
■ ロポジトリの一覧が表示されます。 ■ プロジェクト( ここでは sandbox.git )をクリックして下さい。
sandbox.git
■ プロジェクトの summary が表示されます。 ■ summaryの他に shortlog, log, commit, commitdiff, tree の表示が出来ます