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 initInitialized empty Git repository in /data/git/demo1/demo2/.git/ls -la total 0 drwxr-xr-x 3 root wheel 102 8 9 22:15 . drwxr-xr-x 6 root wheel 204 8 9 22:14 .. drwxr-xr-x 10 root wheel 340 8 9 22:15 .git// readme.md 新建文件 // 把新建的文件添加到git 索引中 (. 不能少,表示当前目录下的所有文件) sudo git add .git status // 查看状态 On branch masterInitial commitChanges to be committed:(use "git rm --cached <file>..." to unstage)new file: readme.md// 提交sudo git commit -am "init"
[master (root-commit) 832bb9e] init1 file changed, 2 insertions(+)create mode 100644 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,denyAllowOverride None# Rquiree all grantedOptions Indexes FollowSymLinks ExecCGIAllow from allSatisfy Any# Enable CGI in this directoryOptions +ExecCGI# Run .cgi files using mod_cgiAddHandler 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_rewriteRewriteEngine 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/$0 [L,PT] </Directory>
在这里注意,我的gitweb 相关的cgi脚本 & 静态的资源(css,img等)都在
/usr/local/share/gitweb/gitweb/
文件下面,如下:
localhost:vhost web$ ls -la /usr/local/share/gitweb/gitweb/ total 504 drwxr-xr-x 5 web admin 170 8 9 01:40 . drwxr-xr-x 3 web admin 102 8 9 01:11 .. -rw-r--r-- 1 web admin 1303 8 9 01:40 gitweb-css.conf -rwxr-xr-x 1 web admin 251379 8 9 01:15 gitweb.cgi drwxr-xr-x 6 web admin 204 8 9 01:11 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 = 50;# This makes repo links use pretty URLs like /git/repo.git $feature{'pathinfo'}{'default'} = [1];
编辑 gitweb.cgi 在文件的 约77 行处,可以找到 our $GIT 这里 设置git 的安装路径(如果安装git路径不配置不正确,会报500内部错误)
73 # core git executable to use74 # this can just be "git" if your webserver has a sensible PATH75 #our $GIT = "/usr/local/git/bin/git";76 #our $GIT = "/usr/local/bin/git";77 our $GIT = "/usr/bin/git";78 79 # absolute fs-path which will be prepended to the project path80 #our $projectroot = "/pub/scm";81 our $projectroot = "/pub/git";
第一行可以看到 #!/usr/bin/perl 字样,使用perl 写的页面(好羡慕 ?)
1 #!/usr/bin/perl2 3 # gitweb - simple web interface to track changes in git repositories4 #5 # (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>6 # (C) 2005, Christian Gierke7 #8 # This program is licensed under the GPLv2
如何查询自己的git 安装路径
localhost:vhost web$ which git /usr/bin/git
在这里配置之后重启Apache ,在浏览器访问:http://127.0.0.1/git/
giweb附件: http://pan.baidu.com/s/1c0nqjxY
end ~
转载于:https://www.cnblogs.com/web1992/p/4714465.html
gitweb 搭建教程相关推荐
- win2008怎么配置php,Win2008 PHP 配置环境搭建 教程
Win2008 PHP 配置环境搭建 教程 一.准备工作 1.所需软件: MySQL数据库:本文用MySQL-essential-5.0.45-win32.msi PHP : 本文用php-5.2.4 ...
- es springboot 不设置id_es(elasticsearch)整合SpringCloud(SpringBoot)搭建教程详解
注意:适用于springboot或者springcloud框架 1.首先下载相关文件 2.然后需要去启动相关的启动文件 3.导入相关jar包(如果有相关的依赖包不需要导入)以及配置配置文件,并且写一个 ...
- 宝塔服务器环境好不好_服务器环境怎么搭建?(宝塔环境搭建教程)
大家好,欢迎来到西安蓝蜻蜓网络讲坛,上期我们讲的是怎样购买服务器,很多小伙伴都知道了购买服务器的方式方法,那么购买服务器后需要怎么搭建服务器环境呢?那么今天,我们就来讲述下服务器环境怎么搭建? 以宝塔 ...
- php iis mysql windows2003,Windows Server 2003 IIS6.0+PHP5(FastCGI)+MySQL5环境搭建教程 | 系统运维...
准备篇 一.环境说明: 操作系统:Windows Server 2003 SP2 32位 PHP版本:php 5.3.14 MySQL版本:MySQL5.5.25 二.相关软件下载: 1.PHP下载地 ...
- neo4j中文社区 php,neo4j 社区版搭建教程
neo4j搭建教程 版本说明 软件 版本 jdk jdk1.8.0_201 neo4j需要提前按照java8 并且配置好jdk neo4j-community 3.5.14 neo4j 社区版 硬件环 ...
- nginx+tomcat实现Windows系统下的负载均衡搭建教程
下面小编就为大家分享一篇nginx+tomcat实现Windows系统下的负载均衡搭建教程,具有很好的参考价值,希望对大家有所帮助 刚入行没多久就听过'负载均衡'的大名,到现在因为工作接触的少,所以没 ...
- Nginx独立图片服务器搭建教程
Nginx独立图片服务器搭建教程 发布时间:2014-06-04编辑:脚本学堂 本文介绍了nginx独立图片服务器的搭建与配置教程,有需要的朋友参考下. 首先,为什么需要独立图片服务器? 现在主流的网 ...
- win命令安装 安装cmake_win10下VSCode+CMake+Clang+GCC环境搭建教程图解
打算用C/C++把基本的数据结构与算法实现一遍, 为考研做准备, 因为只是想实现算法和数据结构, 就不太想用VisualStudio, 感觉VSCode不错, 遂在网上找了一些教程, 结合自己的需求, ...
- Quorum企业以太坊环境搭建教程
Quorum企业以太坊环境搭建教程 Quorum是一个许可制的以太坊联盟区块链实现,包含了金融巨头JP摩根开发的一个GETH分支版本, 可以在节点之间实现私有和快速的交易.Quorum为保证隐私对节点 ...
最新文章
- 实现windows的负载均衡
- Apache activemq入门示例(maven项目)
- SQL SERVER 2012 修改数据库默认位置不立即生效
- CserialPort类的简单用法
- Docker基础-Docker数据管理
- mac m1下安装kubenetes的dashboard
- 基于主成分分析与支持向量机的人脸识别
- @RequestParam,@RequestBody,@PathVariable注解还分不清吗?
- Web应用中request获取各种获取path或URI,URL的方法
- 如何对web.config进行加密和解密
- SQL:字符串拼接中换行处理
- 【转】雅虎邮箱免费开通POP方法 YAHOO!MAIL YMAIL免费开通POP.SMTP和转发功能
- 海湾火灾自动报警系统中文编码查询表
- linux查看运行的虚拟机,windows,linux,esxi系统判断当前主机是物理机还是虚拟机?查询主机序列号命令...
- 40岁后学习编程是否太晚了?7点技巧让学习变得轻松有趣
- 四年程序员的常用工具清单
- eclipse中的特殊注释TODO FIXME XXX
- 使用ESP8266构建一个简单的温湿度在线监测装置
- c语言fun函数解分段函数,用fun函数编写分段函数程序,用C语言编写
- 深度学习深度前馈网络_深度学习前馈网络中的讲义第1部分