搭建(基于http协议)git服务器的安装配置说明一、软件运行环境:
服务器版本:CentOS 5.10 (Final)
Apache版本:Apache-2.2.3
git 版本: git-1.8.2.3
git访问方式:基于http协议(非ssh协议)
客户端版本:winxp/win7/win8
Eclipse版本:Version: Luna Service Release 1 (4.4.1)
二、搭建(基于http协议)git服务器的安装配置说明:
1、安装Apache
[root@]# yum install httpd
2、安装git
[root@]# yum install git
3、安装gitweb
[root@]# yum install gitweb
4、创建一个git用户,用来运行git服务
[root@]# /usr/sbin/useradd git
5、初始化git仓库:这里我们选择/home/git/sample.git来作为我们的git仓库[root@lwww git]# git init --bare sample.git
出现以下提示:
Initialized empty Git repository in /home/git/ sample.git /
#sample.git是个文件夹
6. 修改sample.git的所有者与所属组。
cd /home/git/sample.git
chown -R apache:apache .#所有者与所属组都是apache
7、 Gitweb的配置
Vi /f
$projectroot = "/home/git/";
8、创建f文件夹
mkdir /etc/httpd/conf/vhost
9、创建用于git用户验证的帐户(可以是多个)
htpasswd -m -c /etc/httpd/conf/vhost/git.passwd zfz #zfz是用户名
10、修改git.passwd文件的所有者与所属组
chown apache:apache /etc/httpd/conf/vhost/git.passwd
#所有者与所属组都是apache
11、设置git.passwd文件的访问权限
chmod 640 /etc/httpd/conf/vhost/git.passwd
12. 修改apache配置文件f
vi /etc/httpd/f
#添加如下的内容:
<VirtualHost *:80>
<VirtualHost *:80>
ServerName 192.168.71.187
</VirtualHost>
include conf/vhost/*.conf
#说明:
#ServerName是git服务器的域名或IP
13、 Git的配置
Vi /etc/httpd/conf/f
SetEnv GIT_PROJECT_ROOT /home/git/
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias / /usr/bin/git-http-backend/
<Location />
DAV on
如何搭建git服务器Order allow,deny
Allow from all
AuthType Basic
AuthName "Git"
AuthUser
Require valid-user
</Location>
#说明:
#/home/git是代码库存放的文件夹
#ScriptAlias是将以/ sample.git作为repository. path # AuthUserFile是验证用户帐户的文件
14、重启apache使设置生效
service httpd restart
三、使用Eclipse测试git服务器如下:
1.新建一个java项目
点击上图Java Project后出现以下界面
点击上图Finish后出现以下界面
2、建立本地git仓库
点击上图Share Project后出现以下界面
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论