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;
    }

}


你可能感兴趣的:(git)