centos 安装 giweb

安装 gitweb 代码

1
2
3
4
$ git clone git://git.kernel.org/pub/scm/git/git.git
$ cd git
$ make GITWEB_PROJECTROOT="/opt/git" prefix=/usr gitweb
$ sudo cp -Rf gitweb /var/www/gitweb

安装 fastcgi

1
2
3
4
yum install -y spawn-fcgi  # fastcgi需要通过 spawn-fcgi 来启动, 也可以不安装
yum install -y fcgi
yum install -y fcgi-devel
yum install -y perl-CGI-Session

安装 fcgiwrap

1
2
3
4
5
git clone https://github.com/gnosek/fcgiwrap.git
cd fcgiwrap
./configure
make
make install

spawn-fcgi 配置文件

使用 root 用户将导致 fastcgi 无法启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
vim /etc/sysconfig/spawn-fcgi
# You must set some working options before the "spawn-fcgi" service will work.
# If SOCKET points to a file, then this file is cleaned up by the init script.
#
# See spawn-fcgi(1) for all possible options.
#
# Example :
#SOCKET=/var/run/php-fcgi.sock
#OPTIONS="-u apache -g apache -s $SOCKET -S -M 0600 -C 32 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi"
FCGI_SOCKET=/var/run/fcgiwrap.socket
FCGI_PROGRAM=/usr/local/sbin/fcgiwrap
FCGI_USER=git
FCGI_GROUP=git
FCGI_EXTRA_OPTIONS="-M 0700"
OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"

配置开机启动

1
2
chkconfig spawn-fcgi on  
/etc/init.d/spawn-fcgi start

修改 gitweb 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
vim /etc/gitweb.conf

$projectroot = "/home/git/repositories";

@git_base_url_list= ("git://192.168.3.10", "http://192.168.3.10:5555");
$git_temp = "/home/git/.tmp";
$home_text = "indextext.html";
@stylesheets = ("gitweb.css");
$javascript = "gitweb.js";
@diff_opts = ();
$feature{pathinfo}{default} = [1];
$feature{'highlight'}{'default'} = [1];

nginx 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
server {
listen 5555;
server_name _;
index gitweb.cgi;
root /var/www/gitweb;
location ~ \.(cgi|pl).*$ {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /var/www/gitweb/gitweb.cgi;
fastcgi_param SCRIPT_NAME gitweb.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))$ {
# root /home/git;
# }
# location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
# root /home/git;
# fastcgi_param QUERY_STRING $query_string;
# fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
# fastcgi_param GIT_HTTP_EXPORT_ALL true;
# fastcgi_param GIT_PROJECT_ROOT /home/git/repositories;
# fastcgi_param PATH_INFO $uri;
# include fastcgi_params;
# fastcgi_pass unix:/var/run/fcgiwrap.socket;
# }
try_files $uri @gitweb;
location @gitweb {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /var/www/gitweb/gitweb.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
include fastcgi_params;
}
error_log /var/log/nginx/git.error.log;
access_log /var/log/nginx/git.access.log;
}

gitweb 只是git repos的浏览器, 它并不提供克隆,但是可以用 snapshort 下载代码。