git web 服务器的搭建【转】
转自:http://blog.csdn.net/transformer_han/article/details/6450200
git服务器搭建过程
需求
硬件需求:一台Ubuntu或者debian电脑(虚拟机),能通过网络访问到。
软件需求:git-core, gitosis, openssh-server, openssh-client, Apache2(Gitweb)
安装配置git服务器
a@server:~$ sudo useradd -m git
a@server:~$ sudo mkdir /home/repo
a@server:~$ sudo chown git:git /home/repo
a@server:~$ sudo chmod 700 /home/repo
安装配置gitosis
a@server:~$ git config –global user.name “myname”
a@server:~$ git config –global user.email “myname@server“
a@server:~$ sudo apt-get install python-setuptools
a@server:~$ cd /tmp
a@server:/tmp$ git clone git://eagain.net/gitosis.git
a@server:/tmp$ cd gitosis
a@server:/tmp/gitosis$ sudo python setup.py install
a@server:/tmp/gitosis$ su git
$ ln -s /home/repo /home/git/repositories
$ exit
usr@pc1:~$ ssh-keygen -t rsa
将公钥拷贝到服务器的/tmp下:
usr@pc1:~$ scp .ssh/id_rsa.pubgit@<server>:/tmp
a@server:/tmp/gitosis$ sudo chmod a+r /tmp/id_rsa.pub
a@server:/tmp/gitosis$ sudo -H -u git gitosis-init < /tmp/id_rsa.pub
Initialized empty Git repository in /home/repo/gitosis-admin.git/
Reinitialized existing Git repository in /home/repo/gitosis-admin.git/
a@server:/home/git$ sudo passwd root
a@server:/home/git$ su
root@server:/home/git# cd repositories
root@server:/home/git/repositories# cd gitosis-admin.git/
root@server:/home/git/repositories/gitosis-admin.git#sudo
chmod 755 /home/repo/gitosis-admin.git/hooks/post-update
root@server:/home/git/repositories/gitosis-admin.git# exit
在服务器上新建一个测试项目仓库
我建了一个叫“teamwork”的仓库。
切换到Git用户:
a@ubuntu:/home/git$ su - git
$ cd /home/prj_git
$ mkdir teamwork.git
$ cd teamwork.git
$ git init --bare
$ exit
管理gitosis的配置文件
刚刚提到,gitosis本身的配置也是通过git来实现的。在你自己的开发机里,把gitosis-admin.git这个仓库clone下来,就可以以管理员的身份修改配置了。
fatal: The remote end hung up unexpectedly
root@server:/home/a/work/gitosis-admin# cp /path/to/.ssh/id_rsa.pub ./keydir/b.pub
root@server:/home/a/work/gitosis-admin# exit
[gitosis][group hello_ro]
readonly = teamwork
members = lz
team组有a,b两个成员,该组对teamwork仓库有读写权限;
team_ro组有lz一个成员,对teamwork仓库有只读权限。
加入新文件、提交并push到git服务器:
usr@pc1:~/work/gitosis-admin$ git add .
usr@pc1:~/work/gitosis-admin$ git commit -am “add teamweok prj and users”
usr@pc1:~/work/gitosis-admin$ git push origin master
初始化测试项目
usr@pc1:~/work$ cd teamwork-ori/
usr@pc1:~/work/teamwork-ori$ git init
usr@pc1:~/work/teamwork-ori$ git commit -am “initial version”
usr@pc1:~/work/teamwork-ori$ git push origin master
$ vim hello
$ git add .
$ git commit -am “b add”
$ exit
添加已有git项目
首先需要从你的工作仓库中得到一个纯仓库, 比如你的工作目录为~/kernel, 你想导出纯仓库到你的优盘里,然后拷贝到gitserver上去。
$ git clone –bare ~/kernel /media/udisk
然后就拿着优盘,交给gitserver的管理员,让他拷贝到/home/repo/下,同时需要配置 gitosis相关配置文件哦,这个就不用再说了吧。比如:下载ALSA库:
git clone git://android.git.kernel.org/platform/external/alsa-lib.git
git clone git://android.git.kernel.org/platform/external/alsa-utils.git
git clone –bare alsa-lib alsa-lib.git
git clone –bare alsa-utils alsa-utils.git
配置gitweb
1. 安装gitweb
sudo apt-get install gitweb
2. 安装apache2
sudo apt-get install apache2
3. 配置gitweb
(1)默认没有 css 加载,把 gitweb 要用的静态文件连接到 DocumentRoot 下:
cd /var/ www/
sudo ln -s / usr/ share/ gitweb/* .
(注意后面的点)
(2)修改配置:
sudo vi /etc/ gitweb.conf
将 $projectroot 改为gitosis-admin.git所在目录:
/home/git/repositories
(3)修改 /home/git/repositories权限,默认情况下,gitosis将repositories权限设置为不可读的
sudo chmod 777 -R /home/git/repositories
11.编辑apache2配置文件,建立web站点 (默认情况下可以忽略此步骤)
(1) 编辑apache2配置文件
ubuntu中默认的web目录是/var/www,默认的cgi目录是 /usr/lib/cgi-bin/,安装完成gitweb后,gitweb的gitweb.cgi会自动放置
到该目录下。如果你的cgi路径不是默认的/usr/lib/cgi-bin/,需要将gitweb安装在/usr/lib/cgi-bin中的gitweb.cgi复制到原来配置
的cgi-bin路径,并修改apache的配置文件/etc/apache2/apache.conf:
SetEnv GITWEB_CONFIG /etc/gitweb.conf
gitweb.conf配置文件形如:(可自行修改,这里不做详细介绍)
<Directory "/srv/www/cgi-bin/gitweb">
Options FollowSymlinks ExecCGI
Allow from all
AllowOverride all
Order allow,deny
<Files gitweb.cgi>
SetHandler cgi-script
</Files>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
</Directory>
(2)重新启动apache:sudo /etc/init.d/apache2 restart,访问http://localhost/cgi-bin/gitweb.cgi
<以下未经测试>
a2dissite gitserver 禁用
a2ensite gitserver 使能
/etc/init.d/apache2 restart 重启
git clone git://git.kernel.org/pub/scm/git/git.git
cd git
make GITWEB_PROJECTROOT=”/home/repo” prefix=/usr gitweb/gitweb.cgi
cd gitweb
cp -av git* /home/repo/
<VirtualHost 172.20.146.39:80>
ServerName 172.20.146.39
DocumentRoot /home/repo
ScriptAlias /cgi-bin/ /home/repo
<Directory /home/repo>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
</Directory>
</VirtualHost>
chmod a+r repo
chmod a+x repo
6./etc/init.d/apache2 restart
git clone http://192.168.1.1/alsa-lib.git
git clone http://192.168.1.1/alsa-utils.git
git访问方式:
git clone git@192.168.1.1:alsa-lib.git
Web网页浏览:
http://192.168.1.1
1.windows文件命名不区分大小 写,而linux支持。这样android源码下载时会出现一下问题。大约有15个文件存在这个问题。
2.库的描述文件在.git文件夹的description文件中。编辑该文件,在gitweb页中就会有 description。
3.gitosis库hooks下的post- update不是由post-update.sample重命名过来的,它们不一样。post-update可以更新工作目录,保持与库一致。没有它配置 文件是不会更新的。
4.(1)git@hello:/home/git$ git add .
error: readlink(“external/openssl/apps/md4.c”): No such file or directory
error: unable to index file external/openssl/apps/md4.c
fatal: adding files failed
(2)root@/external/openssl# git init
Initialized empty Git repository in /external/openssl/.git/
root@/external/openssl# git add .
error: readlink(“apps/md4.c”): No such file or directory
error: unable to index file apps/md4.c
fatal: adding files failed
(3)root@android-2.1_r2$ rm -Rf .repo
root@android-2.1_r2$ find . -name “.git”
| xargs rm -Rf
架设git服务器--使用git-daemon 架设基于git 协议服务器:
git是一个不错的版本管理的工具。现在自己在搞一个简单的应用程序开发,想使用git来进行管理。在Google了配置文档后,还是受了N多的挫折。某些文档质量不高,浪费了好多时间......
好,切入正题:
安装必要的git工具
#apt-get install git git-core
安装好了以后,进行设置
1. 创建一个git目录
#mkdir /git
#cd /git/
#mkdir myproject
2. 创建一个空的git仓库
#git-init-db
3. 创建工程的文件
# echo "My test project" > test.txt
* 此步很重要,如果要在远程clone这个project, 这个project必须是非空的,否则会失败。
4. 使用git命令添加并提交新的文件
#git-add test.txt
#git-commit -m "Init"
至此,本地的git 仓库就创建好了。想要在远程clone这个project,还需要使用git-daemon
5. 安装git-daemon-run. git-daemon-run实际是一个脚本管理工具,用来启动git-daemon.
#apt-get install git-daemon
6. 配置git-daemon-run
#vi /etc/sv/git-daemon/run
可以看到
#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
exec chpst -m64000000 /
git-daemon --verbose --base-path=/var/cache /var/cache/git
将最后一句的git-daemon修改为
git-daemon --verbose --export-all --base-path=/git/
* 这里,我加上了一个--export-all.看下man手册就可以知道,使用该选项后,在git仓库中就不必创建git-daemon-export-ok文件。如果不使用该选项,则在第4步还需要创建该文件,即
#touch git-daemon-export-ok
7.重启系统
由于小弟还不知道如何使用git-daemon-run工具重启git-daemon,干脆重启下系统
8. 从client导出server(192.168.35.69)上的myproject
git-clone git://192.168.35.69/myproject
=============================================
branch 操作:
在本地:
git branch test
git checkout test // git branch branch1 branch2
git push original test
git web 服务器的搭建【转】的更多相关文章
- CentOS下Web服务器环境搭建LNMP一键安装包
CentOS下Web服务器环境搭建LNMP一键安装包 时间:2014-09-04 00:50来源:osyunwei.com 作者:osyunwei.com 举报 点击:3797次 最新版本:lnmp- ...
- 服务器上的 Git - 在服务器上搭建 Git
http://git-scm.com/book/zh/v2/%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E5%9C%A8%E6%9C%8D%E ...
- 基于windows IIS的C语言CGI WEB服务器环境搭建
网页编程对我来说特别亲切,因为我就是从html.ASP.PHP一步步接触编程的.自己的编程爱好也是从那里一点一点被满足.不过离开大学之后很久没有碰过WEB了,最近看到嵌入式中的涉及到的web服务器,了 ...
- web服务器环境搭建(及请求代理)
集成开发环境:(前端开发还是使用下面单独的web服务器比较好,前后端分离会用到代理的功能) 1.安装xampp时,软件会自动安装 微软的 Microsoft Visual C++ 2008 Redi ...
- Linux下Web服务器环境搭建LNMP一键安装包[20130911更新]
2012年08月14日 ⁄ LNMP ⁄ 评论数 73 ⁄ 被围观 25,200次+ 最新版本:lnmp-2.4 安装说明:请保证服务器能够正常上网.服务器系统时间准确.yum命令可以正常使用! 1. ...
- Win7+花生壳6.0+tomcat打做自己的web服务器(搭建自己的网站)(参考)
链接地址:http://blog.csdn.net/zhu_9527/article/details/23344623?utm_source=tuicool&utm_medium=referr ...
- Web服务器amp搭建
- php dday1... web服务器的搭建 数据库的安装....
- Git本地服务器搭建及使用详解
Git本地服务器搭建及使用 Git是一款免费.开源的分布式版本控制系统.众所周知的Github便是基于Git的开源代码库以及版本控制系统,由于其远程托管服务仅对开源免费,所以搭建本地Git服务器也是个 ...
随机推荐
- 6.1 python+appium元素定位方式(登录app)
1.0.0 :常见的十种元素定位方式 .driver.find_element_by_id() #id定位 .driver.find_element_by_name() #name定位(已经凉 ...
- (原)自定义资源预览工具:DZAssetPreviewPlugin(1)
@author: 白袍小道 转载请说明,谢谢 题记 后续工具制作单独作为一本(小道用的是OneNote,这样发布简单点.*--*) 总计放到写完后. 目的 1.快速预览资源(因为大部分 ...
- Visual Studio 2005安装包
点击下载
- Week7 Teamework from Z.XML-任务分配
任务分配 Z.XML任务初步分配新鲜出炉,请关注! 初步估计,我们的项目需要191小时.但是根据敏捷开发的方法,我们将在开发过程中根据情况迅速调整任务分配,以适应当时问题.
- 关于配置tomcat多版本同eclipse的配置问题
最近很多同学都在反应tomcat和eclipse关联的问题,其他问题网上搜索下大多都有结果,有比较疑难杂症的,下面贴出: 有的同学之前配置过tomcat6的版本或者在此之前做过配置,现在配置tomca ...
- Zebra - zebra command to get printer error and warning status
1 Flag2 Nibble 16-93 Nibble 8-44 Nibble 35 Nibble 26 Nibble 1
- 前端工程师必须要知道的SEO技巧(1):rel=nofollow的使用
前提:最近我在找工作,想面试一些关于前端的工作,被问到了一些关于SEO优化的问题.我深深的感觉我所回答的太过于表面,没有深入.所以,又把SEO的内容看了一遍.自己总结如下:有的是看的其他博友的贴子,发 ...
- [ZJOI2008]骑士 DP dfs
---题解--- 题解: 观察题面可以很快发现这是一棵基环内向树(然而并没有什么用...) 再稍微思考一下,假设将这个环中的任意一点设为root,然后去掉root到下面的特殊边(即构成环的那条边),那 ...
- BZOJ_day9
哇,一道巨大的水题害得我wa了无数次... 总结一下教训 大家一定记住(给我自己看的) 位运算 一定要加()!!! 重要的事情说三遍 位运算 一定要加()!!! 位运算 一定要加()!!! 位运算 ...
- BZOJ 3270 博物馆 && CodeForces 113D. Museum 期望概率dp 高斯消元
大前提,把两个点的组合看成一种状态 x 两种思路 O(n^7) f[x]表示在某一个点的前提下,这个状态经过那个点的概率,用相邻的点转移状态,高斯一波就好了 O(n^6) 想象成臭气弹,这个和那个的区 ...