Friday, March 20, 2009

Gitweb on EC2

  • Setup EC2 with a debian image, this example is based on AMI - ami-7cfd1a15
  • apt-get upgrade
  • apt-get install git-core gitk gitweb
  • Setup up gitosis and test the git works with a client
Follow the article in this link
Also, check the gitosis documentation, click here
To setup git repository with gitosis, here are some excellent articles to get started with
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

Sample Gitosis conf can be found at http://eagain.net/gitweb/?p=gitosis.git;a=blob;f=example.conf;hb=master

  • So now gitosis is working fine and gitweb has been installed. Lets assume following values * Git trees are in /srv/git/repositories
  • Lets configiure apache for virtual hosts, so that gitdomain.com gives us the gitweb
  • In /var/www create following dirs mkdir -p /var/www/gitdomain.com {cgi-bin}
  • In the cgi-bin directory, copy the , git-favicon.png, git-logo.png, gitweb.cgi and gitweb.css files.
  • Configure the /etc/gitweb.conf file for gitweb settings
vi /etc/gitweb.conf
# path to git projects (.git)
$projectroot = "/srv/git/repositories";

# directory to use for temp files
$git_temp = "/tmp";

# target of the home link on top of all pages
#$home_link = $my_uri || "/";

# html text to include at home page
$home_text = "indextext.html";

# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;

# stylesheet to use
$stylesheet = "/gitweb.css";

# logo to use
$logo = "/git-logo.png";

# the 'favicon'
$favicon = "/git-favicon.png";

#Enable blame, pickaxe search, snapshop, search, and grep
# support, but still allow individual projects to turn them off.
# These are features that users can use to interact with your Git trees. They
# consume some CPU whenever a user uses them, so you can turn them off if you
# need to. Note that the 'override' option means that you can override the
# setting on a per-repository basis.
$feature{'blame'}{'default'} = [1];
$feature{'blame'}{'override'} = [1];

$feature{'pickaxe'}{'default'} = [1];
$feature{'pickaxe'}{'override'} = [1];

$feature{'snapshot'}{'default'} = [1];
$feature{'snapshot'}{'override'} = [1];

$feature{'search'}{'default'} = [1];

$feature{'grep'}{'default'} = [1];
$feature{'grep'}{'override'} = [1];


  • Now lets create the virtual host setting in apache2
1. vi /etc/apache2/sites-available/gitdomain.com

ServerName gitdomain.com
DocumentRoot "/var/www/gitdomain.com/cgi-bin"
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf

ScriptAlias /cgi-bin/ /var/www/gitdomain.com/cgi-bin

Options Indexes FollowSymlinks ExecCGI
Allow from all
AllowOverride None
Order allow,deny


SetHandler cgi-script


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]


2. a2ensite gitdomain.com

3. Restart apache service apache2 restart

This should get you going on gitweb, Make sure you are running apache2 from a different user and not as a root.
To tell apache to use a different user , vi /etc/apache2/envvars and add the users settings there

Reference Links
http://hokietux.net/blog/?p=58



1 comment:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

    ReplyDelete