首页 > 代码库 > Windows平台使用Gitblit搭建Git服务器图文教程
Windows平台使用Gitblit搭建Git服务器图文教程
Git服务现在独树一帜,相比与SVN有更多的灵活性,最流行的开源项目托管网站Github上面,如果托管开源项目,那么就是免费使用的,但是闭源的项目就会收取昂贵的费用,如果你不缺米,那么不在本文讨论的范围内,既然这样,我们可以自己搭建我们的Git服务器。
国内使用Windows Server平台的用户占大多数,那么本文就来讨论如何在Windows平台下搭建Git服务器。
Windows平台下Git服务器搭建
第一步:下载Java,下载地址:http://www.java.com/zh_CN/
<iframe id="iframe_0.7792216416599322" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201507099871589.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.7792216416599322‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第二步:安装Java.安装步骤不再详述。
<iframe id="iframe_0.27526840492214344" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201507475346059.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.27526840492214344‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第三步:配置Java环境变量.
右键”计算机” => ”属性” => ”高级系统设置” => ”高级” => “环境变量” => “系统变量”。
- 新建:
变量名:JAVA_HOME
变量值:D:\Program Files (x86)\Java\jdk1.6.0_21【具体要根据你自己的安装路径,我的是安装在D盘的】
<iframe id="iframe_0.7011814394285556" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201508079092318.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.7011814394285556‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
2. 新建:
变量名:CLASSPATH
变量值:%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar
<iframe id="iframe_0.5463637565473864" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201510347218570.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.5463637565473864‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
3. 添加:找到PATH变量,选择编辑。把%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin添加到”变量值”的结尾处。
<iframe id="iframe_0.0004772222333657705" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201510531286025.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.0004772222333657705‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第四步:验证Java是否安装成功。
打开命令窗口=> 输入CMD => 确定。
<iframe id="iframe_0.3617353548394846" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201511356285343.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.3617353548394846‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
在命令窗口中,输入java命令:javac,回车,如果出现如下信息,说明安装成功。
<iframe id="iframe_0.8772853055524201" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201511547531886.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.8772853055524201‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第五步:下载Gitblit.下载地址:http://www.gitblit.com/
<iframe id="iframe_0.4646457223558018" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201512044561051.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.4646457223558018‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第六步:解压缩下载的压缩包即可,无需安装。
<iframe id="iframe_0.25621028771554566" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201512184247919.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.25621028771554566‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第七步:创建用于存储资料的文件夹。
<iframe id="iframe_0.2708483985284249" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201512340181616.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.2708483985284249‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第八步:配置gitblit.properties 文件。
- 找到Git目录下的data文件下的gitblit.properties文件,“记事本”打开。
<iframe id="iframe_0.6431135396793832" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201513163468647.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.6431135396793832‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
2.找到git.repositoriesFolder(资料库路径),赋值为第七步创建好的文件目录。
<iframe id="iframe_0.14812516821415578" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201513457064983.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.14812516821415578‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
3.找到server.httpPort,设定http协议的端口号
<iframe id="iframe_0.6440187541178157" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201513598312665.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.6440187541178157‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
4.找到server.httpBindInterface,设定服务器的IP地址。这里就设定你的服务器IP。
<iframe id="iframe_0.21843155821087534" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201514127534645.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.21843155821087534‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
5.找到server.httpsBindInterface,设定为localhost
<iframe id="iframe_0.34543945251277686" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201517137534808.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.34543945251277686‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
6.保存,关闭文件。
第九步:运行gitblit.cmd 批处理文件。
- 找到bitblit目录中的gitblit.cmd文件,双击。
<iframe id="iframe_0.38637074924201165" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201518472688379.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.38637074924201165‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe><iframe id="iframe_0.9898122330714676" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201518599241047.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.9898122330714676‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
2.运行结果如下,运行成功。
<iframe id="iframe_0.8461566875542506" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201519353158657.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.8461566875542506‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第十步:在浏览器中打开,现在就可以使用GitBlit了。
<iframe id="iframe_0.946075452598717" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201519569561402.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.946075452598717‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
第十一步:设置以Windows Service方式启动Gitblit.
- 在Gitblit目录下,找到installService.cmd文件。
<iframe id="iframe_0.478421019023215" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201521102064513.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.478421019023215‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
2.用“记事本”打开。
<iframe id="iframe_0.24806860352281035" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201521369565619.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.24806860352281035‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
3.修改 ARCH
32位系统:SET ARCH=x86
64位系统:SET ARCH=amd64
4.添加 CD 为程序目录
SET CD=D:\Git\Gitblit-1.6.0(你的实际目录)
<iframe id="iframe_0.04838290419282609" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201522236288910.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.04838290419282609‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
5.修改StartParams里的启动参数,给空就可以了。
<iframe id="iframe_0.4978400746361473" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201522433315797.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.4978400746361473‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
6.保存,关闭文件。
第十二步:以Windows Service方式启动Gitblit.
1.双击Gitblit目录下的installService.cmd文件(以管理员身份运行)。
<iframe id="iframe_0.8872880437528943" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201523116128403.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.8872880437528943‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
2.在服务器的服务管理下,就能看到已经存在的gitblit服务了。
<iframe id="iframe_0.31588517558955287" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22http://www.uedsc.com/wp-content/uploads/2015/06/201523482688203.png?_=5626240%22%20style=%22border:none;max-width:941px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img‘);%20window.parent.postMessage(%7BiframeId:‘iframe_0.31588517558955287‘,width:img.width,height:img.height%7D,%20‘http://www.cnblogs.com‘);%7D%3C/script%3E" frameborder="0" scrolling="no" width="320" height="240"></iframe>
3.平时使用时,保持这个服务是启动状态就可以了。
以上就是Windows平台下,配置Git服务器的全部的全部内容。
来源:http://www.uedsc.com/windows-gitblit-git-server.html
Windows平台使用Gitblit搭建Git服务器图文教程