您好,欢迎来到外链网!
当前位置:外链网 » 站长资讯 » 专业问答 » 文章详细 订阅RssFeed

在VMware+centOS 8上基于http协议搭建Git服务的方法(centos 8 vmware tools)

来源:互联网 浏览:61次 时间:2023-04-08
内容介绍
  • 一.起因
  • 二.设备信息
  • 三.准备工作
  • 四.安装apache
  • 五.配置git
  • 六.配置apache
  • 七.Android终端访问上述Git服务

一.起因

一定要看

在VMware centOS 8上基于http协议搭建Git服务

本文最终目的是实现Android终端访问虚拟机中git服务,所以需要搭建http协议的git服务器,而如何搭建http协议的git服务器,前人之述备矣,笔者遂借鉴前人之作这里

二.设备信息

在VMware centOS 8上基于http协议搭建Git服务

windows10家庭中文版(1903) VMware 15Pro(15.5.0 build-14665864) centOS 8(1905已关闭GUI,VMware采用NAT模式)

三.准备工作

mac用vm虚拟机安装centos一直重启 Linux 一 安装VM12和centos6.8

(一)windows防火墙开放80端口控制面板 -> 系统和安全 -> Windows Defender 防火墙点击高级设置 -> 点击入站规则 -> 新建规则更改要创建的规则类型为端口按照图示方式设置

选择允许连接并下一步按照图示方式设置

名称设置随意点击出站规则 -> 新建规则后续步骤与上述入站规则设置保持一致

(二) 关闭SELinux

打开selinux配置文件

vi /etc/selinux/config

修改为SELINUX=disabled 重启centOS即可永久关闭SELinux

注:

1.SELinux一共有3种状态,分别是Enforcing,Permissive和Disabled 2.查看当前状态命令: getenforcing 3.临时关闭命令: setenforce 0 4.临时开启:setenforce 1(不可用于永久关闭后的开启)

(三)更改虚拟网络编辑器点击VMware菜单栏编辑 -> 虚拟网络编辑器 -> 更改设置点击VMnet8 NAT模式 -> NAT设置 -> 添加按照图示方式设置(虚拟机IP地址通过ifconfig查询,描述随意)

四.安装apache

(一)安装httpd

yum install httpd

(二)启动httpd服务

systemctl start httpd.service

(三)修改firewalld配置文件和重启firewalld

 firewall-cmd --zone=public --add-port=80/tcp --permanent systemctl restart firewalld.service

如果嫌麻烦可直接关闭防火墙

注:

1.看防火墙状态:systemctl status firewalld 2.暂时关闭防火墙:systemctl stop firewalld 3.永久关闭防火墙: systemctl disable firewalld 4.重启防火墙:systemctl enable firewalld(该命令可永久开启防火墙)

五.配置git

(一)创建空仓库

mkdir -p /home/gitrepo/share.git //空仓库可设置于任意内容介绍下cd /home/gitrepo/share.gitgit init --barechown -R apache:apache /home/gitrepo

(二)创建账号并设置权限

htpasswd -m -c /etc/httpd/conf.d/git-team.htpasswd XXX //XXX为账户名可任意设定chown apache:apache /etc/httpd/conf.d/git-team.htpasswdchmod 640 /etc/httpd/conf.d/git-team.htpasswd

六.配置apache

(一)编辑配置文件

vi /etc/httpd/conf/httpd.conf

在最后一行IncludeOptional conf.d/*.conf的上面添加如下内容

<VirtualHost *:80>
 ServerName X.X.X.X #centOS的IP地址
 SetEnv GIT_HTTP_EXPORT_ALL
 SetEnv GIT_PROJECT_ROOT /home/gitrepo #此处应与创建空仓库的位置一致
 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
 <Location />
 AuthType Basic
 AuthName "Git"
 AuthUserFile /etc/httpd/conf.d/git-team.htpasswd
 Require valid-user
 </Location>
</VirtualHost>

(二)重启httpd

systemctl restart httpd.service

注:

1.查询httpd服务状态 :systemctl status httpd.service 2.查询httpd服务是否为开机启动: systemctl is-enabled httpd.service 3.设置httpd服务为开机启动状态:systemctl enable httpd.service 4.设置httpd服务为开机不启动状态:systemctl disable httpd.service

完成上述操作后即可在外网进行git操作,例如clone

git clone http://windows的IP地址/git/share.git

七.Android终端访问上述Git服务

(www.Downzz.com)

提取码: 9cgu

至此,我们搭建了基于http协议的Git服务,通过Pocket Git实现Android与电脑中的centOS 8互传文件。

总结

以上所述是小编给大家介绍的在VMware+centOS 8上基于http协议搭建Git服务的方法,希望对大家有所帮助!

本文从互联网转载,来源地址:www.downzz.com/fuwuqi/187425.html,原作者保留一切权利,若侵权或引用不当,请联系茶猫云(cmy.cn)删除。【茶猫云,优质云服务器提供商】


找个云服务器