常见3种Git服务器的构建

学习Git不同的服务器形式,具体如下:

- 创建SSH协议服务器

- 创建Git协议服务器

- 创建HTTP协议服务器

方案: Git支持很多服务器协议形式,不同协议的Git服务器,客户端就可以使用不同的形式访问服务器.常见的服务器协议有SSH协议、Git协议、HTTP协议.

拓扑图:

步骤:

一, SSH协议服务器(支持读写操作)

1. 在web1上创建基于密码验证的SSH协议服务器

    [root@web1 ~]# git init --bare /var/git/base_ssh

    Initialized empty Git repository in /var/git/base_ssh/

2. 客户端web2访问

    [root@web2 ~]# git clone root@192.168.2.100:/var/git/base_ssh

    [root@web2 ~]# rm -rf base_ssh

3.客户端web2生成SSH密钥,实现免密码登陆git服务器

   [root@web2 ~]# ssh-keygen -/root/.ssh/id_rsa -N ''

   [root@web2 ~]# ssh-copy-id 192.168.2.100

   [root@web2 ~]# git clone root@192.168.2.100:/var/git

   [root@web2 ~]# git push

二, Git协议服务器(只读操作的服务器)

1. web1上安装git-daemon软件包

    [root@web1 ~]# yum -y install git-daemon

2. web1上创建版本库

    [root@web1 ~]# git init --bare /var/git/base_git

    Initialized empty Git repository in /var/git/base_git/

3. 在web1上修改配置文件,启动git服务

    [root@web1 ~]# vim /usr/lib/systemd/system/git@.service

   修改前:

                ExecStart=-/usr/libexec/git-core/git-daemon --base-path=/var/lib/git

                --export-all --user-path=public_git --syslog --inetd –verbose

    修改后:

               ExecStart=-/usr/libexec/git-core/git-daemon --base-path=/var/git

               --export-all --user-path=public_git --syslog --inetd –verbose

     [root@web1 ~]# systemctl start git.socket

4. 客户端web2访问

    [root@web2 ~]# git clone git://192.168.2.100/base_git

三, HTTP协议服务器(只读操作的服务器)

1. web1上安装gitweb、httpd软件包

    [root@web1 ~]# yum -y install httpd gitweb

2. web1上修改配置文件,设置仓库根目录

    [root@web1 ~]# vim +11 /etc/gitweb.conf

    $projectroot "/var/git";       #添加这一行

3. web1上创建版本仓库

    [root@web1 ~]# git init --bare /var/git/base_http

4. web1启动httpd服务器

    [root@web1 ~]# systemctl start httpd

5. 客户端web2访问

    注意:调用虚拟机中的firefox浏览器,需要在远程时使用ssh -X 服务器IP,并且确保真实主机的firefox已经关闭

    [root@web2 ~]# firefox http://192.168.2.100/git/

结束.

想了解更多关于常见3种Git服务器的构建的内容,请扫微信
或微信搜索jiemingpan

本文链接:http://www.soufuzi.com/jianzhan/2405

(0)
上一篇 2024-08-08 14:32:52
下一篇 2024-08-08 14:32:52

相关推荐

  • oz是什么单位_1oz等于多少毫升多少克

    oz是什么单位 OZ是英文ounce的,中文名“盎司”(香港译为安士)是英制计量单位,作为重量单位时也称为英两。 作为质量单位 常衡盎司:质量单位,整体缩写为oz.av。 1盎司 = 28.349523125克 1盎司 = 16打兰(dram) 1盎司 = 437.5格林 16盎司 = 1磅(pound) 金衡盎司:质量单位,整体缩写为oz.tr(英)、oz.t(美),常见于金银等贵金属的计量。 1盎司 = 480格林 1盎司 =

    2023-04-01 23:12:00
  • ARVIXE主机介绍

    Arvixe位于美国加利福尼亚州圣路易斯奥比斯波,成立于2003年,是美国较早的一个主机商之一。Arvixe也是一家发展较快的虚拟主机公司,公司从开始主要提供虚拟主机服务,后来逐步扩大到VPS主机和独享主机等。其机房位于美国西海岸,拥有基于Linux和Windows操作系统的主机服务,尤以Windows主机出名。和其他主机相比,Arvixe在价格和服务上有绝对的优势,正如宣传所说,他们要在“性价比,稳定性和客户服务上给用户带来最好的体验”。

    2023-03-10 08:46:01