cgit nginx 安装配置

cgit 编译安装

1
2
3
4
git clone  https://git.zx2c4.com/cgit
make get-git
make
make install

安装 高亮插件

1
yum install -y highlight

配置高亮

1
2
3
4
5
6
7
8
9
vim /usr/local/lib/cgit/filters/syntax-highlighting.sh

# This is for version 2
# 注释这行
#exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null

# This is for version 3
# 解注释这行
exec highlight --force -f -I -O xhtml -S "$EXTENSION" 2>/dev/null

配置 cgit css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
vim /var/www/htdocs/cgit/cgit.css
body.hl { background-color:#e0eaee; }
pre.hl { color:#000000; background-color:#e0eaee;
font-size:10pt;
font-family:'Courier New',monospace;}
.hl.num { color:#b07e00; }
.hl.esc { color:#ff00ff; }
.hl.str { color:#bf0303; }
.hl.pps { color:#818100; }
.hl.slc { color:#838183; font-style:italic; }
.hl.com { color:#838183; font-style:italic; }
.hl.ppc { color:#008200; }
.hl.opt { color:#000000; }
.hl.ipl { color:#0057ae; }
.hl.lin { color:#555555; }
.hl.kwa { color:#000000; font-weight:bold; }
.hl.kwb { color:#0057ae; }
.hl.kwc { color:#000000; font-weight:bold; }
.hl.kwd { color:#010181; }

cgit 配置文件 /etc/cgitrc

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
source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.sh
virtual-root=/

#css logo.
css=/cgit.css
logo=/cgit.png

#project
scan-path=/home/git/repositories

local-time=1
#...
enable-index-links=1
enable-index-owner=1
enable-log-filecount=1
enable-log-linecount=1
snapshots=tar.gz tar.bz zip
enable-commit-graph=1
enable-subject-links=1
enable-http-clone=1
enable-commit-graph=1
enable-html-serving=1
enable-blame=1
#title
root-title=qianrushi.org git repositories

#desc
root-desc=Git repositories

nginx 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
        listen 80;
        server_name _;
        root /var/www/htdocs/cgit;
        location ~* ^.+\.(css|png|ico)$ {
                expires 30d;
        }
        location / {
                index cgit.cgi;
                fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                fastcgi_param HTTP_HOST $server_name;
                fastcgi_param PATH_INFO $uri;
                fastcgi_param QUERY_INFO $uri;
                include "fastcgi_params";


        }
        access_log /var/log/nginx/cgit_access.log;
        error_log /var/log/nginx/cgit_error.log warn;
}

fast CGI