How to install Gitolite and Gitoweb on Ubuntu 14.x

Gitolite and Gitweb allow anyone to have its own private repository with ssh access and configuration via simple text files and git commits. Today I have set on journey of installing it on our production server. Configuring gitolite was a breeze, following the manual specified below, but making Gitweb work was major pain, because of my lacking skills as Linux admin. Here is a short manual to save time to everyone else.

  1. Follow this fantastic tutorial to setup git and gitweb. This tutorial leaves you with everything installed correctly, excpet for the configuration of Apache.

  2. If you are working on a clean install of Ubuntu, it is very probable that CGI is not enabled on your server, and only fcgid is enabled. Enable CGI typing:

    sudo ln -s /etc/apache2/mods-available/cgid.load /etc/apache2/mods-enabled/
    sudo ln -s /etc/apache2/mods-available/cgid.conf /etc/apache2/mods-enabled/
    
  3. What remains is to configure the Apache server modifying the file /etc/apache2/sites-enabled/000-default.conf:
    </VirtualHost>
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/
    
      ScriptAlias /cgi-bin/ "/usr/share/gitweb/"
      Alias /cgi-bin/static "/usr/share/gitweb/static"
    
      <Directory "/usr/share/gitweb">
        Options Indexes FollowSymlinks ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
      </Directory>
    
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    
  4. Restart Apache using sudo service apache2 restart

  5. That’s it! Now your application is available at http://localhost/cgi-bin/index.cgi

  6. I was having problems with css and javascript not loaded properly since Gitoweb was trying to access the files on non-existing url. While it should normally work, in case you have a similar problem, you have to modify the /usr/share/gitweb/gitweb.cgi file as following (we are adding backslashes):

    # URI of stylesheets
    our @stylesheets = ("/static/gitweb.css");
    # URI of a single stylesheet, which can be overridden in GITWEB_CONFIG.
    our $stylesheet = undef;
    # URI of GIT logo (72x27 size)
    our $logo = "/static/git-logo.png";
    # URI of GIT favicon, assumed to be image/png type
    our $favicon = "/static/git-favicon.png";
    # URI of gitweb.js (JavaScript code for gitweb)
    our $javascript = "/static/gitweb.js";
    
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s