Git on apache 2.2 with gitweb

What do you need.

  • linux server (in my case ubuntu 12.04.4)
  • git-core (available via apt-get)
  • gitweb (also available via apt-get)

Installing the packages

This tutorial will install Git on apache 2.2 with gitweb

I’m going to assume that you know the basics of linux and that you should have no problem with installing packages through apt-get install and know how to configure them.

First we start off with the installation of git-core. Most of the time it is already installed on Ubuntu. But if not here is the command.

 Creating you git repository

I have created a Git repository under /var/lib/git, this can be any location on your machine. For the sake of the tutorial i’m going to stick with /var/lib. This was done because of a side installation of Trac.First, prepare a folder for your repository.

Change the YourProject to an useful name for your repository, like website or development.
Next, initialize your git repository

In the command line you can see that we chown the repository, this is for gitweb that you install later on.
Next  head in to your repository and open the .git folder. Now prepare the hooks folder

Git is now ready to accept HTTP requests, but at the moment there is no way to authenticate with git. Make a file in your conf.d folder of apache2 and name it git.conf. Add the following lines in the file.

And restart apache2

Now to make the password file for git. I have placed the password file in a seperate folder in the /etc/ folder.

after this you can just user htpasswd passwd.git <user> to add other users. For this to work you have be inside the directory.

Installing gitweb

This couldn’t be more simple under Ubuntu.

And you’re done. If you now open http://<ip/domain>/gitweb you will see gitweb. But there is an error that there is no projects. Let’s start configuring gitweb.

You will get the following

Now change the $projectroot to the root of your git repositories. In my case that is /var/lib/git. Now save and exit.

Last, do for every repository the following command

You should now be able to login with HTTP over git and use your repository.

For more info about Git and Ubuntu

All web pages open in a new tab or window.

Git book from SCM
Ubuntu docs

Leave a Reply