更改

跳到导航 跳到搜索
添加2,332字节 、 2021年4月16日 (五) 23:47
建立内容为“在 Ubuntu 服务器中使用 GitWeb。 sudo apt install highlight fcgiwrap git == Nginx 配置 == 使用本配置时克隆地址为 <code><nowiki>htt…”的新页面
在 [[Ubuntu]] 服务器中使用 GitWeb。

sudo apt install highlight fcgiwrap git

== [[Nginx]] 配置 ==

使用本配置时克隆地址为 <code><nowiki>https://git.example.com/clone/</nowiki>''project''</code>。

<syntaxhighlight lang=nginx>
server {
server_name git.example.com;

location ~ /clone(/.*) {
client_max_body_size 0;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param GIT_PROJECT_ROOT /srv/git;
fastcgi_param PATH_INFO $1;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}

location /gitweb.cgi {
root /usr/share/gitweb;
gzip off;
include fastcgi_params;
fastcgi_param SCRIPT_NAME $uri;
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location / {
root /usr/share/gitweb;
index gitweb.cgi;
}
}
</syntaxhighlight>

== 配置 ==

配置文件为 <code>/etc/gitweb.conf</code>。
<syntaxhighlight lang=perl>
# path to git projects (<project>.git)
$projectroot = "/srv/git";

# directory to use for temp files
$git_temp = "/tmp";

# html text to include at home page
$home_text = "/srv/git/indextext.html";

# stylesheet to use
#@stylesheets = ("static/gitweb.css");

# javascript code for gitweb
#$javascript = "static/gitweb.js";

# logo to use
#$logo = "static/git-logo.png";

# the 'favicon'
#$favicon = "static/git-favicon.png";

# git-diff-tree(1) options to use for generated patches
#@diff_opts = ("-M");
@diff_opts = ();

# 不显示 owner
$omit_owner = 1;

# 只显示 bare repo 中有 "git-daemon-export-ok" 这个文件的仓库
$export_ok = "git-daemon-export-ok";

# 语法高亮(需要 highlight 包)
$feature{'highlight'}{'default'} = [1];
</syntaxhighlight>

向 <code>/srv/git/indextext.html</code> 中写入需要在主页中额外添加的文字。

<syntaxhighlight lang=bash>
echo 'My personal git repos' | sudo tee /srv/git/indextext.html
</syntaxhighlight>

== 外部链接 ==

* [https://git-scm.com/docs/gitweb.conf <code>man gitweb.conf</code>]
* [https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb ProGit 4.7 Git on the Server - GitWeb]
* [https://blog.ruo-chen.wang/r/7 我的博客:搭建一个 Git 服务器]

[[Category:Server]]

导航菜单