Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1171744
  • 博文数量: 312
  • 博客积分: 12522
  • 博客等级: 上将
  • 技术积分: 3376
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-27 18:35
文章分类

全部博文(312)

文章存档

2016年(3)

2015年(1)

2013年(1)

2012年(28)

2011年(101)

2010年(72)

2009年(13)

2008年(93)

分类: IT业界

2011-08-28 19:15:06

    git + gitolite + git-daemon + gitweb setup on Ubuntu 10.10

  • This works on Ubuntu Server 11.04 as well.
  • Fixed the section at the bottom about editing /etc/sv/git-daemon/run because I forgot to include the bits about changing the base-path and directory. Sorry bout that…

  • Added bits about setting gitweb owner and description

  • Added url rewrite bits

  • Added optional bits for /etc/gitweb.conf

  • Added gitweb theme

So here’s the skinny on getting git, gitolite, git-daemon, and gitweb set up on your Ubuntu 10.10 server using the packages from apt.

Make sure to read this entirely and follow every step!

git setup

Install git and doc:

sudo apt-get install git-core git-doc
gitweb setup

Install gitweb:

sudo apt-get install highlight gitweb # update /etc/gitweb.conf to customize
gitolite setup

Install gitolite:

sudo apt-get install gitolite

(optional setup so that gitolite doesn’t complain about not having user and email setup)

sudo su gitolite git config --global user.name "gitolite" git config --global user.email gitolite@your.domain exit

Append www-data to gitolite group so gitweb can access the repos:

sudo usermod -a -G gitolite www-data

Reboot (or something else to make sure that /etc/group is read)

sudo reboot

Change the gitweb configuration to use the gitolite repo paths:

sudo emacs /etc/gitweb.conf # change $projectroot to /var/lib/gitolite/repositories # change $projects_list to /var/lib/gitolite/projects.list

Copy over your pubkey from your local machine to the git server:

# FROM YOUR LOCAL MACHINE scp ~/.ssh/id_rsa.pub git.server:/tmp/username.pub

Initialize gitolite:

# ON THE GIT SERVER chmod 666 /tmp/username.pub sudo -H -u gitolite gl-setup /tmp/username.pub

Change permissions on existing repos to allow gitweb and git-daemon export:

sudo chmod g+r /var/lib/gitolite/projects.list sudo chmod -R g+rx /var/lib/gitolite/repositories

Change gitolite config so that new repos are given permissions to enable gitweb and git-daemon export:

sudo emacs /var/lib/gitolite/.gitolite.rc # change to $REPO_UMASK = 0027; # gets you 'rwxr-x---'
git-daemon setup
sudo apt-get install git-daemon-run

Now we need to change the sv config for git-daemon so that it runs as the gitdaemon user and gitolite group (since gitolite group has read access to the repositories)

sudo emacs /etc/sv/git-daemon/run

Change:

#!/bin/sh exec 2>&1 echo 'git-daemon starting.' exec chpst -ugitdaemon \ "$(git --exec-path)"/git-daemon --verbose --base-path=/var/cache /var/cache/git

to:

IMPORTANT: notice the change from -ugitdaemon to -ugitdaemon:gitolite

#!/bin/sh exec 2>&1 echo 'git-daemon starting.' exec chpst -ugitdaemon:gitolite \ "$(git --exec-path)"/git-daemon --verbose --base-path=/var/lib/gitolite/repositories /var/lib/gitolite/repositories

Reboot the machine:

sudo reboot

To test if everything is working, from your local machine, clone the gitolite-admin.git repository that’s created automatically by the gitolite setup script and enable gitweb and git-daemon export:

# FROM YOUR LOCAL MACHINE git clone gitolite@git.server:gitolite-admin.git cd gitolite-admin emacs conf/gitolite.conf

Change the testing repo to:

repo testing RW+ = @all R = gitweb R = daemon

which gives gitweb and git-daemon read access to testing.git.

If you want to set and owner and description for the gitweb page to use, change it to:

repo testing RW+ = @all R = daemon testing "Owner" = "Test repo"

Setting the repo owner and description automatically gives read access to gitweb so you don’t have to specify it explicitly.

Save the file, commit it, and then push to the server:

git commit -a -m "Enable gitweb and git-daemon export for testing." git push

Now you should be able to see the testing repository in gitweb at:

and you should be able to clone it via the git protocol:

git clone git://git.server/testing.git

To enable pretty gitweb urls ( instead of as explained in ):

Open /etc/apache2/conf.d/gitweb:

sudo emacs /etc/apache2/conf.d/gitweb

and comment out everything.

Enable rewrites in apache:

sudo a2enmod rewrite sudo /etc/init.d/apache2 restart

Add a new ‘git’ virtual host:

sudo emacs /etc/apache2/sites-available/git

and add the following:

    ServerName git.server
    ServerAdmin webmaster@git.server
    DocumentRoot /usr/share/gitweb

    
        Options FollowSymLinks ExecCGI
        AddHandler cgi-script cgi
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
    

brought to you by .

Enable the new ‘git’ virtual host:

sudo a2ensite git sudo /etc/init.d/apache2 reload

Enable pretty urls in /etc/gitweb.conf:

sudo emacs /etc/gitweb.conf

and add the following:

# Enable PATH_INFO so the server can produce URLs of the # form: # This allows for pretty URLs *within* the Git repository, where # my Apache rewrite rules are not active. $feature{'pathinfo'}{'default'} = [1];

To enable other optional features of gitweb, add the following:

$projects_list_description_width = 100; # 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; $feature{'show-sizes'}{'default'} = [1]; $feature{'show-sizes'}{'override'} = 1; $feature{'avatar'}{'default'} = ['gravatar']; $feature{'avatar'}{'override'} = 1; $feature{'highlight'}{'default'} = [1]; $feature{'highlight'}{'override'} = 1;

To add a customized theme (the one I use at ):

sudo mv /usr/share/gitweb/static/gitweb.js /usr/share/gitweb/static/gitweb.js.orig sudo mv /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.orig cd /tmp git clone git://github.com/kogakure/gitweb-theme.git cd gitweb-theme sudo cp gitweb.css gitweb.js /usr/share/gitweb/static/
阅读(1820) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~