«

»

Sep 16

Print this Post

Install Gitweb on your host

GitToday we will see how to install gitweb on our (shared) host (I’m always talking about host because all the tests are done on my shared host service, always Bluehost ;) , most of all because if you want to install a service like this, on your personal server you can simply install it by RPM/DEB package).

The big problem is where I can find gitweb? Directly within the git sources ;) This means if you have installed git from sources you have already build gitweb too and you just need to install it.

[email protected] [~/git-2011-09-07/gitweb]# ll
total 300
drwxr-xr-x  3 mornatin mornatin   4096 Sep 16 12:51 ./
drwxr-xr-x 19 mornatin mornatin  12288 Sep 14 14:31 ../
-rw-r--r--  1 mornatin mornatin  18130 Aug 30 13:35 INSTALL
-rw-r--r--  1 mornatin mornatin   5508 Aug 30 13:35 Makefile
-rw-r--r--  1 mornatin mornatin  18849 Aug 30 13:35 README
-rwxr-xr-x  1 mornatin mornatin 231347 Aug 30 13:35 gitweb.perl*
drwxr-xr-x  3 mornatin mornatin   4096 Sep 14 14:31 static/

Here you can see a not-built git web project, located in “latest” git sources (git-2011-09-07) gitweb folder. So, if you just want to install gitweb without git (for example to get latest version of gitweb without changing your git) you can enter this directory and run a simple make.

[email protected] [~/git-2011-09-07/gitweb]# make
    SUBDIR ../
make[1]: `GIT-VERSION-FILE' is up to date.
    GEN gitweb.cgi

Now, il all worked well, looking in gitweb folder, you can find a cgi file.

[email protected] [~/git-2011-09-07/gitweb]# ll
total 536
drwxr-xr-x  3 mornatin mornatin   4096 Sep 16 12:59 ./
drwxr-xr-x 19 mornatin mornatin  12288 Sep 14 14:31 ../
-rw-r--r--  1 mornatin mornatin    815 Sep 16 12:59 GITWEB-BUILD-OPTIONS
-rw-r--r--  1 mornatin mornatin  18130 Aug 30 13:35 INSTALL
-rw-r--r--  1 mornatin mornatin   5508 Aug 30 13:35 Makefile
-rw-r--r--  1 mornatin mornatin  18849 Aug 30 13:35 README
-rwxr-xr-x  1 mornatin mornatin 231143 Sep 16 12:59 gitweb.cgi*
-rwxr-xr-x  1 mornatin mornatin 231347 Aug 30 13:35 gitweb.perl*
drwxr-xr-x  3 mornatin mornatin   4096 Sep 14 14:31 static/

What you need to do now is just to copy the cgi script in your apache and all static files (in the static folder inside the gitweb one).

cp *.cgi /home/user/public_html/git
cp static/* /home/user/public_html/git

Now you have to configure your gitweb service creating the file gitweb_config.perl in the same place of cgi file (in this example /home/user/public_html/git). In this file you can cut&paste this code

# where is the git binary?
$GIT = "/usr/bin/git";

# where are our git project repositories?
$projectroot = "/home/user/repositories";

# what do we call our projects in the gitweb UI?
$home_link_str = "My gitweb service";

#  where are the files we need for gitweb to display?
@stylesheets = ("gitweb.css");
$logo = "git-logo.png";
$favicon = "git-favicon.png";

# what do we call this site?
$site_name = "My Gitweb";

Where you have to specify: the location of git bin, the place of your git repository (the root directory where all git projects are located, git web will check for git repository starting from this path), and optionally some style stuffs and descriptions).

The only thing remaining is the configuration of your .htaccess file (or a httpd/conf.d/*.conf file if you have root access to your server).
You can configure like this one adding a basic authentication to create a private gitweb service

AuthType Basic
AuthName "git repository"
AuthUserFile "/home/user/passwd"
require valid-user
Options +ExecCGI
RewriteEngine On
RewriteRule ^$ gitweb.cgi
RewriteRule ^([?].*)$ gitweb.cgi$1

The important things to enable gitweb is starting from Options line.

Now you can use gitweb and start browse your projects. Enjoy!

About the author

mmornati

Permanent link to this article: http://blog.mornati.net/2011/09/16/install-gitweb-on-your-host/

7 comments

Skip to comment form

  1. Gabriel

    Useful information and facts! I have been looking for something such as this for some time finally. Thank you!

    [Reply]

  2. William

    Much appreciated for the information and share!

    [Reply]

  3. surya

    Great article. Thanks very much

    [Reply]

  4. Michael Welch

    I’ve followed this article but had questions about the .htaccess.

    I wanted to setup public browsing of my repositories so I started copying on line 5. I now see the gitweb page but there are no repositories visible. A lot of searches mention gitosis and projects_list etc which you made no mention of. Did you assume that this is already setup?

    Thanks

    [Reply]

  5. mmornati

    Hi Michael,
    no I’ve just installed gitweb and git, you don’t need gitosis or other. If you don’t see repositories just check your repositories root path in the cgi script and if your repositories are correctly exported.

    Cheers
    Marco

    [Reply]

  6. Michael Welch

    Thank you very much.

    You provided me with the needed clue. I don’t really know what it means to “export” a repository. I’ve been using git for over a year, but have never hosted a repo myself.

    I found your other post that described how you create your repositories with a script named new_git. I manually executed the commands for one of my repositories and now they all show up in the list.

    I assume I need to actually export all of them so that changes show up with Gitweb?

    Thanks,
    Michael

    [Reply]

  7. mmornati

    Hello Michael,

    hope your gitweb works now. The export part is normally require for the gitdaemon but, if I remember well, I had problems on gitweb too without this export.

    If you have always problems, let me know that I can check on my git repo.

    Marco

    [Reply]

Leave a Reply