Nginx作為gitweb伺服器
阿新 • • 發佈:2019-01-29
安裝nginx和gitweb
sudo apt-get install nginx gitweb
將Gitweb安裝目錄連結到web主目錄下
sudo ln -s /usr/share/gitweb/ /var/www/
安裝spawn-fcgi和fastcgi-wrapper
#安裝 spawn-fcgi
sudo apt-get install spawn-fcgi
#安裝fastcgi-wrapper
git clone https://github.com/gnosek/fcgiwrap.git
cd fcgiwrap
autoreconf -i
./configure
make
make install
#啟動fastcgi-wrapper
sudo spawn-fcgi -f /usr/local/sbin/fcgiwrap -p 9000
修改gitweb.conf
gitweb.cgi 指令碼中有這樣一句話: /etc/gitweb.conf,很顯然,它會讀取 /etc/gitweb.conf 檔案來獲取配置資訊。因此,我們需要在 /etc 下新建一個檔案 gitweb.conf。
vi /etc/gitweb.conf
# path to git projects (<project>.git)
$projectroot = "/home/git/repositories/";
# file with project list; by default, simply scan the projectroot dir.
$projects_list = "/home/git/projects.list";
$feature {'blame'}{'default'} = [1];
$feature {'blame'}{'override'} = 1;
$feature {'snapshot'}{'default'} = ['zip', 'tgz'];
$feature {'snapshot'}{'override'} = 1;
$feature{'highlight'}{'default'} = [1];
nginx.conf
server {
listen 80;
server_name 192.168.0.190;
#靜態檔案目錄
location ~* ^.+\.(css|js|png|jpg|jpeg)$ {
root /var/www;
access_log off;
expires 24h;
}
location ~ ^/gitweb/.*\.cgi$ {
root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.cgi;
include fastcgi.conf;
}
}