「Gitweb」の版間の差分
内部リンク |
項目を整理 |
||
| (3人の利用者による、間の5版が非表示) | |||
| 1行目: | 1行目: | ||
[[Category: |
[[Category:Git ウェブインターフェイス]] |
||
[[en:Gitweb]] |
[[en:Gitweb]] |
||
Gitweb は [[git]] 自体に含まれているデフォルトのウェブインターフェイスで |
Gitweb は [[git]] 自体に含まれているデフォルトのウェブインターフェイスです。 |
||
Gitweb は fcgi をネイティブでサポートしているため、cgi スクリプトとしてラッピングする必要はありません |
Gitweb は fcgi をネイティブでサポートしているため、cgi スクリプトとしてラッピングする必要はありません。[https://sixohthree.com/1402/running-gitweb-in-fastcgi-mode] |
||
== インストール == |
== インストール == |
||
Gitweb をインストールするには、まず {{Pkg|git}} とウェブサーバーをインストールしてください。ここで、テストを行いたい場合は、{{ic|git instaweb}} のヘルプを見て下さい。完全なセットアップをする場合、以下を読んで下さい。 |
Gitweb をインストールするには、まず {{Pkg|git}} と [[ウェブサーバー]] をインストールしてください。ここで、テストを行いたい場合は、{{ic|git instaweb}} のヘルプを見て下さい。完全なセットアップをする場合、以下を読んで下さい。 |
||
以下のすべての例では、{{Pkg|perl-cgi}} パッケージを [[インストール]] する必要があります。({{bug|45431}}) |
|||
ここでは {{Pkg|apache}} を例として用いますが {{Pkg|nginx}}, {{Pkg|lighttpd}} などを使うことも可能です。 |
|||
== Web サーバーの設定 == |
|||
現在の gitweb のデフォルトからウェブサーバーのディレクトリにリンクを作成する必要があります。次の例ではデフォルトのフォルダを使用します: |
|||
# ln -s /usr/share/gitweb /srv/http/gitweb |
|||
=== Apache === |
|||
{{Note|1=サーバーのディレクトリはよく確認してシンボリックリンクを作成してください。}} |
|||
{{ic|/etc/httpd/conf/httpd.conf}} の最後に次の行を追加します: |
|||
== 設定 == |
|||
Alias /gitweb "/usr/share/gitweb" |
|||
=== Apache 2.2 === |
|||
<Directory "/usr/share/gitweb"> |
|||
以下を {{ic|/etc/httpd/conf/httpd.conf}} の最後に追加します: |
|||
<Directory "/srv/http/gitweb"> |
|||
DirectoryIndex gitweb.cgi |
DirectoryIndex gitweb.cgi |
||
Allow from all |
|||
AllowOverride all |
|||
Order allow,deny |
|||
Options ExecCGI |
Options ExecCGI |
||
Require all granted |
|||
<Files gitweb.cgi> |
<Files gitweb.cgi> |
||
SetHandler cgi-script |
SetHandler cgi-script |
||
</Files> |
</Files> |
||
SetEnv GITWEB_CONFIG /etc |
SetEnv GITWEB_CONFIG /etc/gitweb.conf |
||
</Directory> |
</Directory> |
||
または、{{ic|etc/httpd/conf/extra/gitweb.conf}} のような別のファイルに追加します。 |
|||
次に、{{ic|httpd.conf}} の末尾に次の行を追加します: |
|||
<VirtualHost *:80> |
|||
ServerName gitserver |
|||
DocumentRoot /var/www/gitweb |
|||
<Directory /var/www/gitweb> |
|||
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch |
|||
AllowOverride All |
|||
order allow,deny |
|||
Allow from all |
|||
AddHandler cgi-script cgi |
|||
DirectoryIndex gitweb.cgi |
|||
</Directory> |
|||
</VirtualHost> |
|||
# gitweb configuration |
|||
また、設定を {{ic|/etc/httpd/conf/extra/}} の設定ファイルに記述することもできますが、そうするかどうかはあなた次第です。 |
|||
Include conf/extra/gitweb.conf |
|||
Apache が Gitweb の表示を拒否し、代わりに Perl スクリプトのプレーンなソースコードを出力する場合は、Apache が CGI の実行を許可するように設定されていない可能性があります。{{ic|httpd.conf}} で次のコメントが解除されていることを確認してください。 |
|||
==== Apache 2.4 ==== |
|||
<IfModule !mpm_prefork_module> |
|||
Apache 2.4 の場合、{{Pkg|git}} と {{Pkg|apache}} に加えて {{AUR|mod_perl}} をインストールしてください。 |
|||
LoadModule cgid_module modules/mod_cgid.so |
|||
</IfModule> |
|||
{{ic|/etc/httpd/conf/extra/httpd-gitweb.conf}} を作成: |
|||
<IfModule |
<IfModule mpm_prefork_module> |
||
LoadModule cgi_module modules/mod_cgi.so |
|||
Alias /gitweb "/usr/share/gitweb" |
|||
<Directory "/usr/share/gitweb"> |
|||
DirectoryIndex gitweb.cgi |
|||
Require all granted |
|||
Options ExecCGI |
|||
AddHandler perl-script .cgi |
|||
PerlResponseHandler ModPerl::Registry |
|||
PerlOptions +ParseHeaders |
|||
SetEnv GITWEB_CONFIG /etc/gitweb/gitweb.conf |
|||
</Directory> |
|||
</IfModule> |
</IfModule> |
||
{{ic|httpd.service}} を [[再起動]] して、これらの変更を適用します。Apache を使用した CGI 実行の詳細については、https://httpd.apache.org/docs/2.4/howto/cgi.html を参照してください。 |
|||
以下の行を {{ic|/etc/httpd/conf/httpd.conf}} のモジュールセクションに追記: |
|||
LoadModule perl_module modules/mod_perl.so |
|||
以下の行を {{ic|/etc/httpd/conf/httpd.conf}} の最後に追加: |
|||
# gitweb configuration |
|||
Include conf/extra/httpd-gitweb.conf |
|||
=== Lighttpd === |
=== Lighttpd === |
||
以下を {{ic|/etc/lighttpd/lighttpd.conf}} に追加: |
以下を {{ic|/etc/lighttpd/lighttpd.conf}} に追加: |
||
server.modules += ( "mod_alias", "mod_cgi", "mod_redirect", "mod_setenv" ) |
server.modules += ( "mod_alias", "mod_cgi", "mod_redirect", "mod_setenv" ) |
||
setenv.add-environment = ( "GITWEB_CONFIG" => "/etc/gitweb/gitweb.conf" ) |
setenv.add-environment = ( "GITWEB_CONFIG" => "/etc/gitweb/gitweb.conf" ) |
||
| 86行目: | 58行目: | ||
} |
} |
||
また、GitWeb を正しく表示させるには {{ic|mimetype.assign}} の行に {{ic|".css" => "text/css"}} を追加する必要があります。 |
次に、{{ic|lighttpd.service}} を [[再起動]] して、これらの変更を適用します。また、GitWeb を正しく表示させるには {{ic|mimetype.assign}} の行に {{ic|".css" => "text/css"}} を追加する必要があります。 |
||
=== Nginx === |
=== Nginx === |
||
この場所を nginx 設定に追加します (場所を変更することもできます): |
|||
Nginx に以下の location を追加: |
|||
{{hc|/etc/nginx/nginx.conf| |
{{hc|/etc/nginx/nginx.conf| |
||
location /gitweb.cgi { |
|||
include fastcgi_params; |
include fastcgi_params; |
||
gzip off; |
gzip off; |
||
fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi; |
fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi; |
||
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf; |
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf; |
||
fastcgi_pass unix: |
fastcgi_pass unix:/run/fcgiwrap.sock; |
||
} |
} |
||
| 103行目: | 76行目: | ||
root /usr/share/gitweb; |
root /usr/share/gitweb; |
||
index gitweb.cgi; |
index gitweb.cgi; |
||
} |
|||
}</nowiki> |
|||
}} |
}} |
||
[[Nginx#CGI を動かす]]に従っている場合は {{ic|include fastcgi_params;}} を {{ic|include fastcgi.conf;}} に置き換えて下さい。 |
|||
[[Nginx#CGI 実装]] に従う場合は、{{ic|include fastcgi_params;}} を {{ic|include fastcgi.conf;}} に置き換えてみてください。 |
|||
また、{{Pkg|fcgiwrap}} と {{Pkg|spawn-fcgi}} をインストールして fcgiwrap のサービスファイルを編集する必要があります: |
|||
{{hc|/usr/lib/systemd/system/fcgiwrap.service| |
|||
<nowiki>[Unit] |
|||
Description=Simple server for running CGI applications over FastCGI |
|||
After=syslog.target network.target |
|||
最後に、{{Pkg|fcgiwrap}} ををインストールして {{ic|fcgiwrap.socket}} を [[起動/有効化]] します。 |
|||
[Service] |
|||
Type=forking |
|||
Restart=on-abort |
|||
PIDFile=/var/run/fcgiwrap.pid |
|||
ExecStart=/usr/bin/spawn-fcgi -s /var/run/fcgiwrap.sock -P /var/run/fcgiwrap.pid -u http -g http -- /usr/sbin/fcgiwrap |
|||
ExecStop=/usr/bin/kill -15 $MAINPID |
|||
== Gitweb の設定 == |
|||
[Install] |
|||
WantedBy=multi-user.target</nowiki> |
|||
}} |
|||
最後に、サービスを有効化・再起動: |
|||
{{bc|systemctl enable nginx fcgiwrap |
|||
systemctl start nginx fcgiwrap}} |
|||
すべての設定オプションのリストについては、{{man|5|gitweb.conf}} を参照してください。 |
|||
=== Gitweb の設定 === |
|||
=== 基本設定 === |
|||
次に gitweb の設定ファイルを作成する必要があります。{{ic|/etc/gitweb/gitweb.conf}} ファイルを開いて (ファイルが存在しない場合は作成して) 以下のように記述してください: |
|||
{{hc|/etc/gitweb/gitweb.conf|<nowiki> |
|||
our $git_temp = "/tmp"; |
|||
ファイル {{ic|/etc/gitweb.conf}} を開き (存在しない場合は作成し)、これをその中に配置します: |
|||
{{hc|/etc/gitweb.conf|2= |
|||
# The directories where your projects are. Must not end with a slash. |
# The directories where your projects are. Must not end with a slash. |
||
our $projectroot = "/path/to/your/repositories"; |
our $projectroot = "/path/to/your/repositories"; |
||
| 138行目: | 97行目: | ||
# Base URLs for links displayed in the web interface. |
# Base URLs for links displayed in the web interface. |
||
our @git_base_url_list = qw(git://<your_server> http://git@<your_server>); |
our @git_base_url_list = qw(git://<your_server> http://git@<your_server>); |
||
}} |
|||
</nowiki>}} |
|||
"blame" ビュー (ソースファイルの各行の作成者を表示) を有効にするには、次の行を追加します。 |
|||
"blame" (ソースファイルの各行の著者を表示) を有効にするには、以下の行を追加: |
|||
$feature{'blame'}{'default'} = [1]; |
$feature{'blame'}{'default'} = [1]; |
||
設定が完了したら、 |
設定が完了したら、Web サーバーを [[再起動]] します。 |
||
systemctl restart httpd |
|||
=== リポジトリの追加 === |
|||
lighttpd の場合: |
|||
systemctl restart lighttpd |
|||
リポジトリを追加するには、リポジトリフォルダに移動し、リポジトリを次のように作成します: |
|||
=== シンタックスハイライト === |
|||
$ mkdir my_repository.git |
|||
Gitweb でシンタックスハイライトを使うには、まず {{Pkg|highlight}} パッケージをインストールしてください。 |
|||
$ git init --bare my_repository.git/ |
|||
$ cd my_repository.git/ |
|||
$ touch git-daemon-export-ok |
|||
$ echo "Short project's description" > description |
|||
次に、{{ic|gitweb.config}} ファイルを開き、これを追加します。 |
|||
{{bc|<nowiki>$feature{'highlight'}{'default'} = [1];</nowiki>}} |
|||
{{hc|gitweb.config|2= |
|||
ファイルを保存すればハイライトが有効になります。 |
|||
[gitweb] |
|||
owner = ''Your Name'' |
|||
}} |
|||
これにより、Gitweb の "owner" フィールドが入力されます。必須ではありません。 |
|||
== リポジトリの追加 == |
|||
これは、このリポジトリを、コミットをプッシュする "central" リポジトリストレージとして使用し、オーバーヘッドを最小限に抑え、git デーモンを使用できるようにするために git-daemon-export-ok と --bare がここにあることを前提としています。 |
|||
リポジトリフォルダにリポジトリを追加するには、以下のようにリポジトリを作成: |
|||
mkdir my_repository.git |
|||
git init --bare my_repository.git/ |
|||
cd my_repository.git/ |
|||
touch git-daemon-export-ok |
|||
echo "Short project's description" > description |
|||
リポジトリの作成は以上です。これで http://localhost/gitweb で確認できるようになります (すべてがうまくいったと仮定します) Gitweb CGI スクリプトはリポジトリフォルダーを読み取るだけなので、新しいリポジトリのために Apache を再起動する必要はありません。 |
|||
次に {{ic|config}} ファイルを開いて以下を追加: |
|||
[gitweb] |
|||
owner = Your Name |
|||
=== シンタックスハイライト === |
|||
これで gitweb の "Owner" フィールドが入りますが、必須ではありません。 |
|||
Gitweb でシンタックスハイライトを使うには、まず {{Pkg|highlight}} パッケージをインストールしてください。 |
|||
上記の設定では、このリポジトリをコミットのプッシュ先の"中央"リポジトリストレージとして扱っているので、オーバーヘッドを最小限に抑え、git デーモンを使えるようにするために git-daemon-export-ok と --bare を使っています。 |
|||
highlight をインストールしたら、以下の行を {{ic|gitweb.conf}} に追加します: |
|||
上記の設定でリポジトリが作成できます。全て上手く設定できていれば http://localhost/gitweb で確認できます。gitweb の cgi スクリプトがリポジトリのフォルダを読み込むので、リポジトリを追加したときに apache を再起動する必要はありません。 |
|||
{{bc|<nowiki>$feature{'highlight'}{'default'} = [1];</nowiki>}} |
|||
ファイルを保存すればハイライトが有効になります。 |
|||
== トラブルシューティング == |
|||
=== An error occurred while reading CGI reply (no response received) === |
|||
http://localhost/gitweb をブラウザで開いたときに、このエラーメッセージが表示されることがあります。コマンドラインで {{ic|gitweb.cgi}} を実行することで、完全なエラーメッセージを取得することができます ({{ic|ln -s /usr/share/gitweb /srv/http}} を実行している場合): |
|||
{{hc|$ perl /srv/http/gitweb/gitweb.cgi| |
|||
Can't locate CGI.pm in @INC (you may need to install the CGI module) (@INC contains: /usr/lib/perl5/site_perl |
|||
/usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl |
|||
/usr/share/perl5/core_perl .) at gitweb/gitweb.cgi line 13. |
|||
}} |
|||
この問題を解決するには、{{Pkg|perl-cgi}} をインストールしてください。バグレポートも存在します: {{Bug|45431}}。 |
|||
== 参照 == |
== 参照 == |
||
* [ |
* [https://www.howtoforge.com/how-to-install-a-public-git-repository-on-a-debian-server How To Install A Public Git Repository On A Debian Server] — このページは主に HowtoForge を基にしています。 |
||
2024年2月7日 (水) 00:58時点における最新版
Gitweb は git 自体に含まれているデフォルトのウェブインターフェイスです。
Gitweb は fcgi をネイティブでサポートしているため、cgi スクリプトとしてラッピングする必要はありません。[1]
インストール
Gitweb をインストールするには、まず git と ウェブサーバー をインストールしてください。ここで、テストを行いたい場合は、git instaweb のヘルプを見て下さい。完全なセットアップをする場合、以下を読んで下さい。
以下のすべての例では、perl-cgi パッケージを インストール する必要があります。(FS#45431)
Web サーバーの設定
Apache
/etc/httpd/conf/httpd.conf の最後に次の行を追加します:
Alias /gitweb "/usr/share/gitweb" <Directory "/usr/share/gitweb"> DirectoryIndex gitweb.cgi Options ExecCGI Require all granted <Files gitweb.cgi> SetHandler cgi-script </Files> SetEnv GITWEB_CONFIG /etc/gitweb.conf </Directory>
または、etc/httpd/conf/extra/gitweb.conf のような別のファイルに追加します。
次に、httpd.conf の末尾に次の行を追加します:
# gitweb configuration Include conf/extra/gitweb.conf
Apache が Gitweb の表示を拒否し、代わりに Perl スクリプトのプレーンなソースコードを出力する場合は、Apache が CGI の実行を許可するように設定されていない可能性があります。httpd.conf で次のコメントが解除されていることを確認してください。
<IfModule !mpm_prefork_module> LoadModule cgid_module modules/mod_cgid.so </IfModule> <IfModule mpm_prefork_module> LoadModule cgi_module modules/mod_cgi.so </IfModule>
httpd.service を 再起動 して、これらの変更を適用します。Apache を使用した CGI 実行の詳細については、https://httpd.apache.org/docs/2.4/howto/cgi.html を参照してください。
Lighttpd
以下を /etc/lighttpd/lighttpd.conf に追加:
server.modules += ( "mod_alias", "mod_cgi", "mod_redirect", "mod_setenv" )
setenv.add-environment = ( "GITWEB_CONFIG" => "/etc/gitweb/gitweb.conf" )
url.redirect += ( "^/gitweb$" => "/gitweb/" )
alias.url += ( "/gitweb/" => "/usr/share/gitweb/" )
$HTTP["url"] =~ "^/gitweb/" {
cgi.assign = ( ".cgi" => "" )
server.indexfiles = ( "gitweb.cgi" )
}
次に、lighttpd.service を 再起動 して、これらの変更を適用します。また、GitWeb を正しく表示させるには mimetype.assign の行に ".css" => "text/css" を追加する必要があります。
Nginx
この場所を nginx 設定に追加します (場所を変更することもできます):
/etc/nginx/nginx.conf
location /gitweb.cgi {
include fastcgi_params;
gzip off;
fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
fastcgi_pass unix:/run/fcgiwrap.sock;
}
location / {
root /usr/share/gitweb;
index gitweb.cgi;
}
Nginx#CGI 実装 に従う場合は、include fastcgi_params; を include fastcgi.conf; に置き換えてみてください。
最後に、fcgiwrap ををインストールして fcgiwrap.socket を 起動/有効化 します。
Gitweb の設定
すべての設定オプションのリストについては、gitweb.conf(5) を参照してください。
基本設定
ファイル /etc/gitweb.conf を開き (存在しない場合は作成し)、これをその中に配置します:
/etc/gitweb.conf
# The directories where your projects are. Must not end with a slash. our $projectroot = "/path/to/your/repositories"; # Base URLs for links displayed in the web interface. our @git_base_url_list = qw(git://<your_server> http://git@<your_server>);
"blame" ビュー (ソースファイルの各行の作成者を表示) を有効にするには、次の行を追加します。
$feature{'blame'}{'default'} = [1];
設定が完了したら、Web サーバーを 再起動 します。
リポジトリの追加
リポジトリを追加するには、リポジトリフォルダに移動し、リポジトリを次のように作成します:
$ mkdir my_repository.git $ git init --bare my_repository.git/ $ cd my_repository.git/ $ touch git-daemon-export-ok $ echo "Short project's description" > description
次に、gitweb.config ファイルを開き、これを追加します。
gitweb.config
[gitweb] owner = Your Name
これにより、Gitweb の "owner" フィールドが入力されます。必須ではありません。
これは、このリポジトリを、コミットをプッシュする "central" リポジトリストレージとして使用し、オーバーヘッドを最小限に抑え、git デーモンを使用できるようにするために git-daemon-export-ok と --bare がここにあることを前提としています。
リポジトリの作成は以上です。これで http://localhost/gitweb で確認できるようになります (すべてがうまくいったと仮定します) Gitweb CGI スクリプトはリポジトリフォルダーを読み取るだけなので、新しいリポジトリのために Apache を再起動する必要はありません。
シンタックスハイライト
Gitweb でシンタックスハイライトを使うには、まず highlight パッケージをインストールしてください。
highlight をインストールしたら、以下の行を gitweb.conf に追加します:
$feature{'highlight'}{'default'} = [1];
ファイルを保存すればハイライトが有効になります。
参照
- How To Install A Public Git Repository On A Debian Server — このページは主に HowtoForge を基にしています。