gitweb 搭建教程
1. 前言
git 是一个版本控制工具,类似svn.
本文内容主要涉及git仓库通过浏览器访问(用web的方式去查看git提交历史记录,tag,branch等信息),即gitweb.
效果图:


在这里说下 gitweb 的运行流程(组成部分),方便整理思路以及后续查找问题所在,组成图:

想要搭建gitweb 必须准备三个主要环境支持:apache, cgi 运行环境,git
apache 提供浏览器的方式,就如Svn 可以通过浏览器访问一样,都是有apache 的支持
cgi 这里用来解析gitweb.cgi 脚本(就如html 通过浏览器解析,变成网页一样)
git 环境支持,如同运行java程序,一定要有jdk 环境一样
2. git 仓库初始化
这里仓库的作用就如数据库,来存储你的代码
sudo mkdir demo2
cd demo2/ sudo git init Initialized empty Git repository in /data/git/demo1/demo2/.git/ls -la
total
drwxr-xr-x root wheel : .
drwxr-xr-x root wheel : ..
drwxr-xr-x root wheel : .git // readme.md 新建文件
// 把新建的文件添加到git 索引中 (. 不能少,表示当前目录下的所有文件)
sudo git add . git status // 查看状态
On branch master Initial commit Changes to be committed:
(use "git rm --cached <file>..." to unstage) new file: readme.md
// 提交
sudo git commit -am "init"
[master (root-commit) 832bb9e] init
file changed, insertions(+)
create mode readme.md
3. 配置Apache 的cgi模块
cgi 按照可以参照 (http://www.cnblogs.com/web1992/p/4525286.html)
查询你的apache 是否安装了cgi 模块,命令如下
sudo apachectl -M |grep cgi
// 出现这个 cgi-module 表示已经安装了cgi
proxy_fcgi_module (shared)
proxy_scgi_module (shared)
cgi_module (shared)
在 Apache httpd.conf 配置文件中添加
Include /etc/apache2/vhost/*.conf
#这里的意思我的 gitweb.conf 文件放在 /etc/apache2/vhost/ 文件夹下面,
这里通过Apache 的虚拟主机(vhost)来访问gitweb,配置如下(都有英文注释):
localhost:vhost web$ cat gitweb.conf #Alias /git /usr/local/git/share/gitweb
#Alias /git /usr/local/git-share/share/gitweb
Alias /git /usr/local/share/gitweb/gitweb/ <Directory /usr/local/share/gitweb/gitweb/>
#Options +ExecCGI
#AddHandler cgi-script .cgi
#DirectoryIndex gitweb.cgi
# Let anyone see our repositories (for now)
Order allow,deny
AllowOverride None
# Rquiree all granted
Options Indexes FollowSymLinks ExecCGI
Allow from all
Satisfy Any
# Enable CGI in this directory
Options +ExecCGI # Run .cgi files using mod_cgi
AddHandler cgi-script .cgi # Use gitweb.cgi for directory listings. This takes care of
# requests to /git and /git/
# 配置index
DirectoryIndex gitweb.cgi # This tells gitweb.cgi where to find its config file
# By default it looks in /etc/gitweb.conf, so if you place
# your config file somewhere else you should specify this.
#SetEnv GITWEB_CONFIG /etc/gitweb.conf #SetEnv GITWEB_CONFIG /usr/local/git/share/gitweb/gitweb-css.conf
# 这里配置git仓库位置,css 样式, git 安装路径
# gitweb-css.conf 十分重要
SetEnv GITWEB_CONFIG /usr/local/share/gitweb/gitweb/gitweb-css.conf # Enable mod_rewrite
RewriteEngine on # Rewrite /git/repo.git URIs to be /git/gitweb.cgi/repo.git
# This assumes your repository names end with '.git'. I don't
# know if that is always a safe assumption.
RewriteRule ^([^.]+\.git.*)$ /git/gitweb.cgi/$ [L,PT]
</Directory>
在这里注意,我的gitweb 相关的cgi脚本 & 静态的资源(css,img等)都在
/usr/local/share/gitweb/gitweb/
文件下面,如下:
localhost:vhost web$ ls -la /usr/local/share/gitweb/gitweb/
total
drwxr-xr-x web admin : .
drwxr-xr-x web admin : ..
-rw-r--r-- web admin : gitweb-css.conf
-rwxr-xr-x web admin : gitweb.cgi
drwxr-xr-x web admin : static
localhost:vhost web$
4. gitweb cgi脚本配置 & 静态资源配置
gitweb-css.conf 内容:
localhost:vhost web$ cat /usr/local/share/gitweb/gitweb/gitweb-css.conf #####################################################################################
# This is the directory where your git repositories live
# git 的仓库位置,十分重要
$projectroot = '/data/git/'; # This is the title of the site
$site_name = "用用的笨笨笨笨的用用 gitweb site"; # This is used to generate the URI for each repo
$my_uri = "/git"; # Text and URI for the home link
$home_link_str = "My Projects";
# 好像不支持中文 %>_<%
#$home_link_str = "用用的笨笨笨笨的用用 Projects";
$home_link = "/git"; # These tell gitweb the URIs for the images and css it needs.
# Depending on the version of GitWeb you have there may be
# different locations. Newer versions include a /static/ path
# element and a javascript library. ###### OLDER GITWEB ######################
#@stylesheets = ("/git/gitweb.css");
#$logo = "/git/git-logo.png";
#$favicon = "/git/git-favicon.png";
#$javascript = "/git/gitweb.js";
# 这里配置css 样式的路径,如果配置不正确,页面就会很丑的~~
##### NEWER GITWEB #######################
@stylesheets = ("/git/static/gitweb.css");
$logo = "/git/static/git-logo.png";
$favicon = "/git/static/git-favicon.png";
$javascript = "/git/static/gitweb.js"; # This just makes the description field wider so you can read
# it better
$projects_list_description_width = ; # This makes repo links use pretty URLs like /git/repo.git
$feature{'pathinfo'}{'default'} = [];
编辑 gitweb.cgi 在文件的 约77 行处,可以找到 our $GIT 这里 设置git 的安装路径(如果安装git路径不配置不正确,会报500内部错误)
# core git executable to use
# this can just be "git" if your webserver has a sensible PATH
#our $GIT = "/usr/local/git/bin/git";
#our $GIT = "/usr/local/bin/git";
our $GIT = "/usr/bin/git"; # absolute fs-path which will be prepended to the project path
#our $projectroot = "/pub/scm";
our $projectroot = "/pub/git";
第一行可以看到 #!/usr/bin/perl 字样,使用perl 写的页面(好羡慕
gitweb 搭建教程的更多相关文章
- Spring+SpringMvc+Mybatis框架集成搭建教程
一.背景 最近有很多同学由于没有过SSM(Spring+SpringMvc+Mybatis , 以下简称SSM)框架的搭建的经历,所以在自己搭建SSM框架集成的时候,出现了这样或者那样的问题,很是苦恼 ...
- Hbase+ Phoenix搭建教程
Hbase+ Phoenix搭建教程 一.Hbase简介 HBase是基于列存储.构建在HDFS上的分布式存储系统,其主要功能是存储海量结构化数据. HBase构建在HDFS之上,因此HBase也是通 ...
- Windows Server 2003 IIS6.0+PHP5(FastCGI)+MySQL5环境搭建教程
准备篇 一.环境说明: 操作系统:Windows Server 2003 SP2 32位 PHP版本:php 5.3.14(我用的php 5.3.10安装版) MySQL版本:MySQL5.5.25 ...
- Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程
原文地址:http://www.osyunwei.com/archives/7378.html 搬运是为了自己找资料方便. 准备篇 一.环境说明: 操作系统:Windows Server 2012 R ...
- Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程
准备篇 一.环境说明: 操作系统:Windows Server 2012 R2 PHP版本:php 5.5.8 MySQL版本:MySQL5.6.15 二.相关软件下载: 1.PHP下载地址: htt ...
- 【网站搭建教程】黑手VIP卡盟搭建教程(无KEY)
黑手VIP卡盟搭建教程(无KEY)教程介绍:第一课 卡盟介绍与课程流程.exe第七课 卡盟源码的搜集与选择_.exe第三课 卡盟域名之注册.exe第九课 IIS的本机架设_.exe第二课 卡盟域名之选 ...
- LAMP环境搭建教程
原文:LAMP环境搭建教程 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.M ...
- Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程
这篇文章主要介绍了Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程,需要的朋友可以参考下 准备篇 一.环境说明: 操作系统:Windows Server 201 ...
- Win2008 R2 IIS7.5+PHP5(FastCGI)+MySQL5环境搭建教程
现在很多朋友想尝试win2008 r2来跑web服务器,跟win2003相比界面差别有点大,有些人可能不太习惯,不过以后是趋势啊,这里简单分享下,方便需要的朋友 准备篇 一.环境说明: 操作系统:Wi ...
随机推荐
- js 判断是什么浏览器、是否为谷歌浏览器
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http ...
- 用dfs遍历联通块(优化)
一.题目(CF 598D) 输入一个n x m的字符矩阵,求从某个空点出发,能碰到多少面墙壁,总共询问k次.(3 ≤m,n ≤1000,1 ≤ k ≤ min(nm,100 000)) 二.解题思路 ...
- mac上使用命令行显示隐藏文件
终端中输入命令 打开<终端> - 粘贴下面的两行命令执行 defaults write com.apple.finder AppleShowAllFiles TRUEkillall Fin ...
- webpack 使用总结
参考:http://www.ferecord.com/webpack-summary.html#base64 写的比较详细了
- Mac终端(Terminal)自定义颜色,字体,背景
使用Mac作为开发机的时候,苹果终端自带的颜色黑白,字体又小,看起来确实不是很舒服.那推荐大家使用Solarized配色方案.Solarized 是目前最完整的 Terminal/Editor/IDE ...
- Day5 集合的深浅copy
集合是无序的,不重复的数据集合,它里面的元素是可哈希的(不可变类型),但是集合本身是不可哈希(所以集合做不了字典的键)的.以下是集合最重要的两点: 去重,把一个列表变成集合,就自动去重了. 关系测试, ...
- 8 Java 归并排序(MergerSort)
图片素材与文字描述来自:尚硅谷-韩顺平数据结构与算法. 1.基本思想 归并排序是利用归并的思想实现的排序方法,该算法采用经典的分治(divide-and-conquer)策略(分治法将问题分(divi ...
- HTTP协议重定向
HTTP重定向:服务器无法处理浏览器发送过来的请求(request),服务器告诉浏览器跳转到可以处理请求的url上.(浏览器会自动访问该URL地址,以至于用户无法分辨是否重定向了.) 重定向的返回码3 ...
- java在线聊天项目0.2版本 制作客户端窗体,使用swing(用户界面开发工具包)和awt(抽象窗口工具包) BorderLayout布局与GridLayout布局不同之处 JPanel设置大小
代码如下: package com.swift; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JBu ...
- 玩转ApplicationContextAware
当一个类实现了这个接口之后,这个类就可以方便地获得 ApplicationContext 中的所有bean.换句话说,就是这个类可以直接获取Spring配置文件中,所有有引用到的bean对象.结合工厂 ...