Ubuntu10.04搭建Git服务器和GitWeb

安装Git服务器:

 

Ubuntu服务器端:

 

第一步: 安装必备软件模块

ivan@ubuntu:~$ sudo apt-get install git-core openssh-server openssl-client python-setuptools

 

第二步:添加git用户用于管理所有代码仓库和用户权限

ivan@ubuntu:~$ sudo useradd -m git

设置git用户密码:

ivan@ubuntu:~$ sudo passwd git

 

第三步: 安装gitosis

ivan@ubuntu:~$ git clone git://eagain.net/gitosis.git

ivan@ubuntu:~$ cd gitosis

ivan@ubuntu:~$python setup.py install

 

第四步: 切换到git用户并创建git仓库目录

ivan@ubuntu:~$ su git
Password:
$ cd ../git
$ ls
examples.desktop
$ pwd
/home/git
$ mkdir sample.git
$ cd sample.git
$ git --bare init
Initialized empty Git repository in /home/git/sample.git/

Git客服端,初始化sample.git仓库:

Administrator@ivan ~
$ mkdir sample

Administrator@ivan ~
$ cd sample

Administrator@ivan ~/sample
$ git init
Initialized empty Git repository in /home/Administrator/sample/.git/

Administrator@ivan ~/sample
$ touch readme

Administrator@ivan ~/sample
$ git add .

Administrator@ivan ~/sample
$ git commit -m "First Commit"
[master (root-commit) d5ba460] First Commit
 Committer: Ivan.Chen <Administrator@ivan.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name <you@example.com>'

 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme

Administrator@ivan ~/sample
$ git remote add origin git@192.168.1.202:sample.git

Administrator@ivan ~/sample
$ git push origin master
The authenticity of host '192.168.1.202 (192.168.1.202)' can't be established.
RSA key fingerprint is 17:b8:f6:c0:15:b2:7e:6a:12:36:1f:5c:cc:a1:5e:04.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.202' (RSA) to the list of known hosts.
git@192.168.1.202's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 220 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.1.202:sample.git
 * [new branch]      master -> master

 

安装GitWeb

第一步: 安装必备软件模块

ivan@ubuntu:~$ sudo apt-get install gitweb apache2

 

第二步:修改gitweb.conf文件中$projectroot值

ivan@ubuntu:~$ sudo vim /etc/gitweb.conf

 

# path to git projects (<project>.git)
$projectroot = "/home/git";

 

第三步:修改git仓库文件夹的权限

ivan@ubuntu:~$ sudo chmod 777 -R /home/git

 

到目前为止gitweb搭建完毕,即可通过浏览器访问http://192.168.1.202:8001/cgi-bin/gitweb.cgi。192.168.1.202是gitweb服务器的IP地址,端口是8001,这里一般默认是80端口,你可以通过修改一下文件

第一步:

ivan@ubuntu:~$ sudo vim /etc/apache2/sites-available/gitserver

 

<VirtualHost *:8001>
        ServerName localhost

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

        <Directory /usr/lib/cgi-bin/>
                Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
                AllowOverride All
                order allow,deny
                Allow from all
                AddHandler cgi-script cgi .pl .py
                DirectoryIndex gitweb.cgi
        </Directory>
</VirtualHost>

 

第二步:修改apache配置文件

ivan@ubuntu:~$ sudo vim /etc/apache2/ports.conf

 

NameVirtualHost *:80
Listen 80

NameVirtualHost *:8001
Listen 8001

重启apache server

ivan@ubuntu:~$ sudo /etc/init.d/apache2 restart

* Restarting web server apache2

... waiting                                                             [ OK ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值