Gitweb with Lighttpd in Cygwin

Gitweb is a component of git that provide basic repo browsing functionality via perl-based CGI. After scouring the Internet with Google, I was able to find all the pieces necessary for a basic gitweb setup on Windows using Cygwin and lighttpd. I have found this to be useful for viewing my local git repositories.

Below are the steps that I used to setup gitweb to run in lighttpd under Cygwin:

  1. Download and run the Cygwin setup.exe program from http://cygwin.com/install.html

    If you already have Cygwin installed, that should not be a problem. You can still run setup.exe to install additional Cygwin packages.
  2. Proceed through the Cygwin setup process until you get to the "Select Packages" screen. From there, make sure the following packages are selected:
    • Devel -> git
    • Web -> lighttpd
    • Editors -> nano (unless you prefer a different text editor)
  3. Right-click the Cygwin Terminal icon and then click "Run as Administrator".

    Note: On older versions of Windows such as XP and Windows Server 2003, the "Run as Administrator" option may not be available. In that case, simply double-click the Cygwin Terminal shortcut.
  4. Create a new lighttpd configuration by copying the default configuration file. Use the following command:

    cp /etc/lighttpd/lighttpd.conf.default /etc/lighttpd/lighttpd.conf
  5. Open the new lighttpd.conf file in a text editor to make changes by using the following command:

    nano /etc/lighttpd/lighttpd.conf
  6. Make the following changes to the lighttpd.conf file:
    • Uncomment the "mod_cgi" and the "mod_alias" lines in the "server.modules" section by removing the ‘#' character at the beginning of the lines.
    • If you would like to use a port other than the default port 80, uncomment the "server.port" line and set it to the desired port number.
    • Add the following line to the end of the file:

      cgi.assign = (".cgi" => "/usr/bin/perl")
  7. Save the changes to lighttpd.conf and close it. If using nano:
    • Press Ctrl + O, then press Enter to save the file.
    • Press Ctrl + X to exit.
  8. Open/create the gitweb.conf in a text editor to make changes using the following command:

    nano /etc/gitweb.conf
  9. Add the following line to the gitweb.conf file but substitute the parent directory containing all of your git repositories. The following example assumes C:\Projects:

    $projectroot = "/cygdrive/c/Projects";
  10. Save the changes to gitweb.conf and close it. If using nano:
    • Press Ctrl + O, then press Enter to save the file.
    • Press Ctrl + X to exit.
  11. Use the following commands to create directories if they do not already exist:
    • mkdir /srv
    • mkdir /srv/www
    • mkdir /srv/www/htdocs
    • mkdir /var/log/lighttpd
  12. Create a symbolic link to the gitweb directory using the following command:

    ln -s /usr/share/gitweb /srv/www/htdocs/gitweb
  13. Run the following command to create a new "Gitweb" Windows service that will start automatically:

    cygrunsrv -I Gitweb -p /usr/sbin/lighttpd -a "-D -f /etc/lighttpd/lighttpd.conf"
  14. Start the new Gitweb service by running the following command:

    net start Gitweb
  15. Access gitweb in your browser using a URL similar to the one below. Be sure to substitute the correct port number that you specified in the lighttpd.conf file.

    http://localhost:1234/gitweb/gitweb.cgi
Posted in Linux, Windows Tagged with: , , ,
3 comments on “Gitweb with Lighttpd in Cygwin
  1. JohnnyG says:

    thanks so much for putting all of this info together! I got it going right away!

  2. Praveen says:

    Excellent article. Concise and effective. Thanks.

  3. uriya says:

    I ran gitweb service and I got this error:
    The Gitweb service is starting.
    The Gitweb service could not be started.

    The service did not report an error.

    More help is available by typing NET HELPMSG 3534.

    After that I tryed to run lighttpd without gitweb and I got more errors that I solved thanks to this site http://zengrong.net/post/1793.htm
    He said that you should comment out this settings:
    server.event-handler
    server.use-ipv6
    server.network-backend
    server.max-fds
    server.max-connections

Leave a Reply

Your email address will not be published. Required fields are marked *

*