It was a long time since my last post. Unfortunately, I was too busy with my employer’s project to write anything enough interesting to post here. I wrote some drafts, but they stay still as drafts to this day..
Recently I had some thoughts about creating my own web-accessible git repository, so I can have backup of some of my scripts and have them easily clone on other computers if I need to. I configured gitweb for this. You can see how it’s working on my repository page. This post is about how to make gitweb working on shared hosting.
Things you will need
- access your server’s filesystem (ssh, ftp, anything to upload and manipulate files)
- perl (because gitweb is written in perl)
- mod_perl (to run perl on server)
Download git source code
- using browser, wget or something other, download code from: http://git-scm.com/downloads
- or… using git on popular social git website, clone git’s repository (^_^):
Go to the gitweb directory in your downloaded git code.
You can now configure gitweb by passing appropriate arguments to make. You can too configure it later in separate file like me. More info about configuration during build time you will find in INSTALL file.
After that file gitweb.cgi should now exists in your gitweb directory. We are especially interested in this file and the static subdirectory. Upload both of them on the server.
Upload gitweb on your server
Copy gitweb.cgi to the cgi-bin directory (there should be one in public_html). Static dir should go whenever you want, but remember that it should be still accessible from web. Example file hierarchy:
We copied gitweb script to the cgi-bin directory, because most probably apache is configured on your server to execute files from this place. Not just read. If it will not work, add to your .htaccess file: AddHandler cgi-script .cgi So apache will recognize it properly.
For automatically executing gitweb on index page, you can now:
- change default directory index
- link gitweb.cgi as index.cgi
- rename gitweb.cgi to index.cgi
By default when you call gitweb.cgi, it searches in the same directory for: gitweb_config.perl file. Create this file and add following lines:
So example file will look like this:
There are many more variables to override. All of them you can find in README file. Notice that $projectroot doesn’t have to point to publicly available directory.
Additionally, if you moved static to some other directory, renamed it, or changed file names inside, you should take a closer look on following variables in README:
Probably if you read this text, you will be interested in creating remote repositories on server. I’ll write about it later in separate post, trying to deeply explain everything, so stay tuned.