lichaoyue888 发表于 2015-11-13 10:18:43

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

  1. 安装git, gitweb, spawn-fcgi
  yum install -y git gitweb spawn-fcgi fcgi-devel fcgi
  2. 安装fcgiwrap
  wgethttps://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} = ;

  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/(+/+|pack/pack-+.(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;
    }
  }

  

         版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: git的http服务器(nginx)搭建(CentOS 6.5)