gitolite, git-daemon & gitweb on CentOS 6

Posted: February 7, 2013 in Devops, Featured, How To, How To - Linux
Tags: , , ,

I’ve found many tutorials on how to accomplish this on Debian/Ubuntu systems, but not RHEL.

You have to have at least a minimal installation with the EPEL repository enabled.

Install packages

yum install -y git{,web,-daemon,olite} httpd xinetd

Setup Gitolite
Copy your public ssh-key to /tmp and allow gitolite to read it

cp ~/.ssh/ /tmp/$ && chmod 644 /tmp/$

Change to the gitolite user and run gl-setup

sudo -u gitolite -i
gl-setup /tmp/$

Alter the base permissons of the repos and fix what we already have. In /var/lib/gitolite/.gitolite.rc change:
$GL_WILDREPOS to 1; and
$REPO_UMASK to 0027

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

Change the group of the apache user to allow it access to the gitolite repositories

usermod -a -G gitolite apache

Configure git-daemon to only export repositories with a git-daemon-export-ok file inside (created by added R permissions to daemon)

# default: off
# description: The git dæmon allows git repositories to be exported using \
# the git:// protocol.
service git {
disable = no
socket_type = stream
wait = no
user = nobody
group = gitolite
server = /usr/libexec/git-core/git-daemon
server_args = --base-path=/var/lib/gitolite/repositories --syslog --inetd --verbose
log_on_failure += USERID }

Configure /etc/gitweb.conf to point to the right projectroot and project_list (the only 2 lines you actually need are here)

our $projectroot = "/var/lib/gitolite/repositories";
our $projects_list = "/var/lib/gitolite/projects.list";

Make the services persistant (survive a reboot):

chkconfig httpd on
chkconfig xinetd on
service httpd start
service xinetd start

To allow access to gitweb or gitdaemon in the config file, do something like this in your gitolite.conf:

repo    webtest
        R       =   daemon gitweb
        RW+     =   admin

If you need to add these perms to a wildcard repo, you can use the setperm admin command:

echo "READERS gitweb daemon" | ssh gitolite@host setperms path/to/wildrepo

Check it with:

ssh gitolite@host getperms path/to/wildrepo
  1. Thanks for this article, it really helped.
    Had to change my user and group in the httpd.conf to ‘gitolite’ though to get everything working.

    • geogdog says:

      Hi Jamie,

      Thanks for the comment.

      You don’t have to change httpd.conf, I realised that I missed that you have to restart apache after adding the secondary group to the apache user as the current running processes are using the old groups.


      • geogdog says:

        Hang on…

        …I hadn’t even started apache yet, so adding that makes no sense.

        This how-to assumes that you don’t have apache installed yet.

  2. You left out that you need to have EPEL enabled

  3. Andrew Bowns says:

    I’ve completed all the above steps but when I go to the url ‘myserver/git’ I get a 404 No projects found. Any ideas?

  4. […] have hallowed gitolite and gitweb according to a educational in this blog post. The whole thing runs unequivocally good. we am means to reflection and dedicate to a […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s