git的http服务器(nginx)搭建(CentOS 6.5)

1. 安装git, gitweb, spawn-fcgi

yum install -y git gitweb spawn-fcgi fcgi-devel fcgi

2. 安装fcgiwrap

wget  https://codeload.github.com/gnosek/fcgiwrap/legacy.tar.gz/master

tar zxvf fcgiwrap.tar.gz

cd fcgiwrap

autoreconfig

make

make install

3. 编辑/etc/gitweb.conf

$projectroot = "/data/user/repo/git"
$git_temp = "/tmp";
$home_text = "indextext.html";
$projects_list = "/home/git/projects.list";
@stylesheets = ("static/gitweb.css");
$javascript = "static/gitweb.js";
$favicon = "static/eab-favicon.png";
@diff_opts = ();
$feature{pathinfo}{default} = [1];

4. 编辑/etc/nginx/site-enables/git.conf

server {

    listen 80;

    error_log /data/user/log/nginx/git.error.log;
    access_log /data/user/log/nginx/git.access.log;

    client_max_body_size 4000m;
    client_body_buffer_size 8m;

    auth_basic "Restricted";
    auth_basic_user_file /data/user/trac/user.htpasswd;

    location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))$ {
        root /data/user/repo/git;

    # requests that need to go to git-http-backend

    location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
        root /data/user/repo/git;

        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        fastcgi_param SCRIPT_FILENAME   /usr/libexec/git-core/git-http-backend;
        fastcgi_param PATH_INFO         $uri;
        fastcgi_param GIT_PROJECT_ROOT  /data/user/repo/git;
        fastcgi_param GIT_HTTP_EXPORT_ALL "";
        fastcgi_param REMOTE_USER $remote_user;
        include fastcgi_params;
    }


    try_files $uri @gitweb;
    location @gitweb {
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
        fastcgi_param PATH_INFO $uri;
        fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
        include fastcgi_params;
    }

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值