https://wiki.archlinux.org/api.php?action=feedcontributions&user=Pault&feedformat=atomArchWiki - User contributions [en]2024-03-28T15:43:20ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Gitweb&diff=220951Gitweb2012-09-01T11:30:03Z<p>Pault: /* Apache */ s/you/your/</p>
<hr />
<div>[[Category:Version Control System]]<br />
Gitweb is the default web interface provided with [[git]] itself and is the basis for other git scripts like [[cgit]], [[gitosis]] and others.<br />
<br />
==Installation==<br />
To install gitweb you first have to install git and a webserver. For this example we use apache but you can also use others:<br />
pacman -S git apache<br />
<br />
Next you need to link the current gitweb default to your webserver location. In this example I use the default folder locations:<br />
ln -s /usr/share/gitweb /srv/http/gitweb<br />
<br />
That's it for the "installation". Next is the configuration.<br />
<br />
==Configuration==<br />
===Apache===<br />
Add the following to the end of your /etc/httpd/conf/httpd.conf<br />
<Directory "/srv/http/gitweb"><br />
DirectoryIndex gitweb.cgi<br />
Allow from all<br />
AllowOverride all<br />
Order allow,deny<br />
Options ExecCGI<br />
<Files gitweb.cgi><br />
SetHandler cgi-script<br />
</Files><br />
SetEnv GITWEB_CONFIG /etc/conf.d/gitweb.conf<br />
</Directory><br />
<br />
You can put the configuration in it's own config file in /etc/httpd/conf/extra/ but that's up to you to decide.<br />
<br />
===Lighttpd===<br />
If you're using lighttpd, make sure mod_alias, mod_redirect, mod_cgi and mod_setenv are loaded. Add the following to /etc/lighttpd/lighttpd.conf:<br />
server.modules += ( mod_setenv )<br />
setenv.add-environment = ( "GITWEB_CONFIG" => "/etc/conf.d/gitweb.conf" )<br />
url.redirect += ( "^/gitweb$" => "/gitweb/" )<br />
alias.url += ( "/gitweb/" => "/usr/share/gitweb/" )<br />
$HTTP["url"] =~ "^/gitweb/" {<br />
cgi.assign = (".cgi" => "")<br />
server.indexfiles = ("gitweb.cgi")<br />
}<br />
<br />
===Gitweb config===<br />
Next we need to make a gitweb config file. Open (or create if it does not exist) the file {{ic|/etc/conf.d/gitweb.conf}} and place this in it:<br />
{{hc|/etc/conf.d/gitweb.conf|<nowiki><br />
$git_temp = "/tmp";<br />
<br />
# The directories where your projects are. Must not end with a slash.<br />
$projectroot = "/path/to/your/repositories"; <br />
<br />
# Base URLs for links displayed in the web interface.<br />
our @git_base_url_list = qw(git://<your_server> http://git@<your_server>); <br />
</nowiki>}}<br />
<br />
To enable "blame" view (showing the author of each line in a source file), add the following line:<br />
$feature{'blame'}{'default'} = [1];<br />
<br />
Now the the configuration is done, please restart your webserver.<br />
For apache:<br />
/etc/rc.d/httpd restart<br />
<br />
Or for lighttpd:<br />
/etc/rc.d/lighttpd restart<br />
<br />
===Syntax highlighting===<br />
<br />
To enable syntax highlighting with Gitweb, you have to first install the {{Pkg|highlight}} package from <nowiki>[community]</nowiki>:<br />
pacman -S highlight<br />
<br />
When highlight has been installed, simply add this line to your {{ic|gitweb.conf}}:<br />
{{bc|<nowiki>$feature{'highlight'}{'default'} = [1];</nowiki>}}<br />
<br />
Save the file and highlighting should now be enabled.<br />
<br />
==Adding repositories==<br />
To add a repository go to your repository folder, make your repository like so:<br />
mkdir my_repository.git<br />
git init --bare my_repository.git/<br />
cd my_repository.git/<br />
touch git-daemon-export-ok<br />
echo "Short project's description" > description<br />
<br />
Next open the "config" file and add this:<br />
[gitweb]<br />
owner = Your Name<br />
<br />
This will fill in the "Owner" field in gitweb. It's not required.<br />
<br />
I assumed that you want to have this repository as "central" repository storage where you push your commits to so the git-daemon-export-ok and --bare are here to have minimal overhead and to allow the git daemon to be used on it.<br />
<br />
That is all for making a repository. You can now see it on your http://localhost/gitweb (assuming everything went fine). You do not need to restart apache for new repositories since the gitweb cgi script simply reads your repository folder.<br />
<br />
==Thanks to...==<br />
This howto was mainly based on the awesome howto from howtoforge: http://www.howtoforge.com/how-to-install-a-public-git-repository-on-a-debian-server I only picked the parts that are needed to get it working and left the additional things out.</div>Pault