https://wiki.archlinux.org/api.php?action=feedcontributions&user=P1rox&feedformat=atomArchWiki - User contributions [en]2024-03-29T07:25:13ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Gitweb&diff=264908Gitweb2013-07-02T12:30:57Z<p>P1rox: </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 />
{{Note|1=You may want to double check the server directory to make sure the symbolic links were made.}}<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 />
If using a virtualhosts configuration, add this to /etc/httpd/conf/extra/httpd-vhosts.conf<br />
<VirtualHost *:80><br />
ServerName gitserver<br />
DocumentRoot /var/www/gitweb<br />
<Directory /var/www/gitweb><br />
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch<br />
AllowOverride All<br />
order allow,deny<br />
Allow from all<br />
AddHandler cgi-script cgi<br />
DirectoryIndex gitweb.cgi<br />
</Directory><br />
</VirtualHost><br />
<br />
You could also 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 />
Add the following to /etc/lighttpd/lighttpd.conf:<br />
server.modules += ( "mod_alias", "mod_cgi", "mod_redirect", "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 />
You may also need to add {{ic|".css" &#61;> "text/css"}} to the {{ic|mimetype.assign}} line for GitWeb to display properly.<br />
<br />
===Nginx===<br />
Consider you've symlinked {{ic|ln -s /usr/share/gitweb /var/www}}, append this location to your nginx configuration:<br />
{{hc|/etc/nginx/nginx.conf|<br />
<nowiki>location /gitweb/ {<br />
index gitweb.cgi;<br />
include fastcgi_params;<br />
gzip off;<br />
fastcgi_param GITWEB_CONFIG /etc/conf.d/gitweb.conf;<br />
if ($uri ~ "/gitweb/gitweb.cgi") {<br />
fastcgi_pass unix:/var/run/fcgiwrap.sock;<br />
}<br />
}</nowiki><br />
}}<br />
Additionally, we have to install {{ic|pacman -S fcgiwrap spawn-fcgi}} and modify the fcgiwrap service file:<br />
{{hc|/usr/lib/systemd/system/fcgiwrap.service|<br />
<nowiki>[Unit]<br />
Description=Simple server for running CGI applications over FastCGI<br />
After=syslog.target network.target<br />
<br />
[Service]<br />
Type=forking<br />
Restart=on-abort<br />
PIDFile=/var/run/fcgiwrap.pid<br />
ExecStart=/usr/bin/spawn-fcgi -s /var/run/fcgiwrap.sock -P /var/run/fcgiwrap.pid -u http -g http -- /usr/sbin/fcgiwrap<br />
ExecStop=/usr/bin/kill -15 $MAINPID<br />
<br />
[Install]<br />
WantedBy=multi-user.target</nowiki><br />
}}<br />
In the end, enable and restart the services:<br />
{{bc|systemctl enable nginx fcgiwrap<br />
systemctl start nginx fcgiwrap}}<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/gitweb.conf}} and place this in it:<br />
{{hc|/etc/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 />
systemctl restart httpd <br />
<br />
<br />
Or for lighttpd:<br />
systemctl restart lighttpd<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" > .git/description<br />
<br />
Next open the {{ic|.git/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>P1roxhttps://wiki.archlinux.org/index.php?title=Gitweb&diff=264907Gitweb2013-07-02T12:28:32Z<p>P1rox: </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 />
{{Note|1=You may want to double check the server directory to make sure the symbolic links were made.}}<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 />
If using a virtualhosts configuration, add this to /etc/httpd/conf/extra/httpd-vhosts.conf<br />
<VirtualHost *:80><br />
ServerName gitserver<br />
DocumentRoot /var/www/gitweb<br />
<Directory /var/www/gitweb><br />
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch<br />
AllowOverride All<br />
order allow,deny<br />
Allow from all<br />
AddHandler cgi-script cgi<br />
DirectoryIndex gitweb.cgi<br />
</Directory><br />
</VirtualHost><br />
<br />
You could also 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 />
Add the following to /etc/lighttpd/lighttpd.conf:<br />
server.modules += ( "mod_alias", "mod_cgi", "mod_redirect", "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 />
You may also need to add {{ic|".css" &#61;> "text/css"}} to the {{ic|mimetype.assign}} line for GitWeb to display properly.<br />
<br />
===Nginx===<br />
Consider you've symlinked {{ic|ln -s /usr/share/gitweb /var/www}}, append this location to your nginx configuration:<br />
{{hc|/etc/nginx/nginx.conf|<br />
<nowiki>location /gitweb/ {<br />
index gitweb.cgi;<br />
include fastcgi_params;<br />
gzip off;<br />
fastcgi_param GITWEB_CONFIG /etc/conf.d/gitweb.conf;<br />
if ($uri ~ "/gitweb/gitweb.cgi") {<br />
fastcgi_pass unix:/var/run/fcgiwrap.sock;<br />
}<br />
}</nowiki><br />
}}<br />
Additionally, we have to install {{ic|pacman -S fcgiwrap spawn-fcgi}} and modify the fcgiwrap service file:<br />
{{hc|/usr/lib/systemd/system/fcgiwrap.service|<br />
<nowiki>[Unit]<br />
Description=Simple server for running CGI applications over FastCGI<br />
After=syslog.target network.target<br />
<br />
[Service]<br />
Type=forking<br />
Restart=on-abort<br />
PIDFile=/var/run/fcgiwrap.pid<br />
ExecStart=/usr/bin/spawn-fcgi -s /var/run/fcgiwrap.sock -P /var/run/fcgiwrap.pid -u http -g http -- /usr/sbin/fcgiwrap<br />
ExecStop=/usr/bin/kill -15 $MAINPID<br />
<br />
[Install]<br />
WantedBy=multi-user.target</nowiki><br />
}}<br />
In the end, enable and restart the services:<br />
{{bc|systemctl enable nginx fcgiwrap<br />
systemctl start nginx fcgiwrap}}<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/gitweb.conf}} and place this in it:<br />
{{hc|/etc/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 />
systemctl restart httpd <br />
<br />
<br />
Or for lighttpd:<br />
systemctl restart lighttpd<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" > .git/description<br />
<br />
Next open the ".git/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>P1roxhttps://wiki.archlinux.org/index.php?title=Gitweb&diff=264905Gitweb2013-07-02T12:18:48Z<p>P1rox: </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 />
{{Note|1=You may want to double check the server directory to make sure the symbolic links were made.}}<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 />
If using a virtualhosts configuration, add this to /etc/httpd/conf/extra/httpd-vhosts.conf<br />
<VirtualHost *:80><br />
ServerName gitserver<br />
DocumentRoot /var/www/gitweb<br />
<Directory /var/www/gitweb><br />
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch<br />
AllowOverride All<br />
order allow,deny<br />
Allow from all<br />
AddHandler cgi-script cgi<br />
DirectoryIndex gitweb.cgi<br />
</Directory><br />
</VirtualHost><br />
<br />
You could also 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 />
Add the following to /etc/lighttpd/lighttpd.conf:<br />
server.modules += ( "mod_alias", "mod_cgi", "mod_redirect", "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 />
You may also need to add {{ic|".css" &#61;> "text/css"}} to the {{ic|mimetype.assign}} line for GitWeb to display properly.<br />
<br />
===Nginx===<br />
Consider you've symlinked {{ic|ln -s /usr/share/gitweb /var/www}}, append this location to your nginx configuration:<br />
{{hc|/etc/nginx/nginx.conf|<br />
<nowiki>location /gitweb/ {<br />
index gitweb.cgi;<br />
include fastcgi_params;<br />
gzip off;<br />
fastcgi_param GITWEB_CONFIG /etc/conf.d/gitweb.conf;<br />
if ($uri ~ "/gitweb/gitweb.cgi") {<br />
fastcgi_pass unix:/var/run/fcgiwrap.sock;<br />
}<br />
}</nowiki><br />
}}<br />
Additionally, we have to install {{ic|pacman -S fcgiwrap spawn-fcgi}} and modify the fcgiwrap service file:<br />
{{hc|/usr/lib/systemd/system/fcgiwrap.service|<br />
<nowiki>[Unit]<br />
Description=Simple server for running CGI applications over FastCGI<br />
After=syslog.target network.target<br />
<br />
[Service]<br />
Type=forking<br />
Restart=on-abort<br />
PIDFile=/var/run/fcgiwrap.pid<br />
ExecStart=/usr/bin/spawn-fcgi -s /var/run/fcgiwrap.sock -P /var/run/fcgiwrap.pid -u http -g http -- /usr/sbin/fcgiwrap<br />
ExecStop=/usr/bin/kill -15 $MAINPID<br />
<br />
[Install]<br />
WantedBy=multi-user.target</nowiki><br />
}}<br />
In the end, enable and restart the services:<br />
{{bc|systemctl enable nginx fcgiwrap<br />
systemctl start nginx fcgiwrap}}<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/gitweb.conf}} and place this in it:<br />
{{hc|/etc/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 />
systemctl restart httpd <br />
<br />
<br />
Or for lighttpd:<br />
systemctl restart lighttpd<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>P1rox