Skip to content

Git on VPS

by drphrozen on December 21st, 2011

A couple of month ago i bought a Rackspace Cloud Server instance. I set it up using Ubuntu 11.10 (Oneiric) and tried using UberSVN which is very simple to setup and manage. Unfortunately UberSVN uses Apache HTTP Server and Tomcat, which are too demanding for my memory constrained VPS (Virtual Private Server). Instead i tried manually setting up apache and svn, but this also ate a lot of my memory. Instead i ended up replacing apache with nginx (first i tried lighttpd, but it had some issues). I used toofishes blog (and comments) as my guide, here.
Below is the configuration that worked for me:

location ~ /git(/.*) {
  auth_basic                        "Restricted";
  auth_basic_user_file              /svn/.htpasswd;

  fastcgi_split_path_info           ^(.*/git)(/.*)$;
  fastcgi_param SCRIPT_FILENAME     /usr/lib/git-core/git-http-backend;

  # export all repositories under GIT_PROJECT_ROOT
  fastcgi_param GIT_HTTP_EXPORT_ALL "";
  fastcgi_param DOCUMENT_ROOT       /usr/lib/git-core/;
  fastcgi_param GIT_PROJECT_ROOT    /var/lib/gitolite/repositories;
  fastcgi_param PATH_INFO           $fastcgi_path_info;

  include                           /etc/nginx/fastcgi_params;
  fastcgi_pass                      unix:/var/run/fcgiwrap.socket;
}

From → Uncategorized

3 Comments
  1. Hello,

    and thanks for your post, I’ve read toofishes.net tuto and also this one http://blog.teepark.net/git-smart-http-support-through-nginx

    But yours is the only which talk about gitolite (in GIT_PROJECT_ROOT)

    By the way I can’t make it work.

    Whatever the repo name (existent or not ) I give in the clone command I have the following answer :

    git clone http://www.mydomain.fr/git/bb.git
    Cloning into bb…
    warning: remote HEAD refers to nonexistent ref, unable to checkout.

    But if I clone throught gitolite :
    git clone gitolite@192.168.1.111:bb

    It works…

    Have you done something about gitolite rights (chown or anything else) ?
    Any idea ?

  2. drphrozen permalink

    Hi there,

    I used the package that came with Ubuntu (sudo apt-get install gitolite) if you wan’t to use a more edgy version you should maybe follow this guide to set it up:
    http://sitaramc.github.com/gitolite/

    Hope it helps

  3. Thanks, but Gitolite don’t seems to be the causes of my problem, after many hours (3-4) of try here are my nginx log files when I try to clone my repo :

    2012/02/16 14:27:02 [error] 11750#0: *1 FastCGI sent in stderr: “Cannot get script name, is DOCUMENT_ROOT and SCRIPT_NAME set and is the script executable?” while reading response header from upstream, client: x.x.x.x, server: http://www.yyy.fr, request: “GET /git/test.git/info/refs?service=git-upload-pack HTTP/1.1″, upstream: “fastcgi://unix:/var/run/fcgiwrap.socket:”, host: “www.yyy.fr”
    2012/02/16 14:27:02 [error] 11750#0: *1 FastCGI sent in stderr: “Cannot get script name, is DOCUMENT_ROOT and SCRIPT_NAME set and is the script executable?” while reading response header from upstream, client: x.x.x.x, server: http://www.yyy.fr, request: “GET /git/test.git/info/refs HTTP/1.1″, upstream: “fastcgi://unix:/var/run/fcgiwrap.socket:”, host: “www.yyy.fr”

    Any idea ?

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS