How to build Git service based on http protocol on VMware+centOS 8

How to build Git service based on http protocol on VMware+centOS 8

1. Cause

Must see

The ultimate goal of this article is to enable Android terminals to access the git service in the virtual machine, so it is necessary to build a git server with http protocol. How to build a git server with http protocol has been described by predecessors. The author then draws on the predecessors' work here

2. Equipment Information

Windows 10 Home Chinese Edition (1903) VMware 15Pro (15.5.0 build-14665864) CentOS 8 (1905 has closed the GUI, VMware uses NAT mode)

3. Preparation

1. Open port 80 in Windows Firewall. Control Panel -> System and Security -> Windows Defender Firewall. Click Advanced Settings -> Click Inbound Rules -> New Rule. Change the rule type to be created to Port. Set it as shown in the figure.

insert image description here

Select Allow the connection and follow the instructions to set up

insert image description here

Name setting: click Outbound Rules -> Create New Rule. The subsequent steps are consistent with the above inbound rule settings.

2. Disable SELinux

Open the selinux configuration file

vi /etc/selinux/config

Change to SELINUX=disabled and restart centOS to permanently disable SELinux

Note:

1. SELinux has 3 states: Enforcing, Permissive and Disabled 2. View the current state command: getenforcing 3. Temporary shutdown command: setenforce 0 4. Temporary enable: setenforce 1 (cannot be used to enable after permanent shutdown)

(III) Change the virtual network editor. Click Edit in the VMware menu bar -> Virtual Network Editor -> Change Settings. Click VMnet8 NAT Mode -> NAT Settings -> Add. Set it as shown in the figure (the virtual machine IP address is queried through ifconfig, and the description is optional).

4. Install Apache

(I) Install httpd

yum install httpd

(II) Start the httpd service

systemctl start httpd.service

(III) Modify the firewalld configuration file and restart firewalld

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

If you find it troublesome, you can just turn off the firewall

Note:

1. Check the firewall status: systemctl status firewalld 2. Temporarily turn off the firewall: systemctl stop firewalld 3. Permanently turn off the firewall: systemctl disable firewalld 4. Restart the firewall: systemctl enable firewalld (this command can permanently turn on the firewall)

5. Configure git

1. Create an empty warehouse

mkdir -p /home/gitrepo/share.git //The empty repository can be set in any directory cd /home/gitrepo/share.gitgit init --barechown -R apache:apache /home/gitrepo

(II) Create an account and set permissions

htpasswd -m -c /etc/httpd/conf.d/git-team.htpasswd XXX //XXX is the account name and can be set arbitrarily chown apache:apache /etc/httpd/conf.d/git-team.htpasswdchmod 640 /etc/httpd/conf.d/git-team.htpasswd

6. Configure Apache

1. Edit the configuration file

vi /etc/httpd/conf/httpd.conf

Add the following content above the last line of IncludeOptional conf.d/*.conf

<VirtualHost *:80>
 ServerName XXXX #centOS IP address SetEnv GIT_HTTP_EXPORT_ALL
 SetEnv GIT_PROJECT_ROOT /home/gitrepo #This should be consistent with the location where the empty repository is created 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>

(II) Restart httpd

systemctl restart httpd.service

Note:

1. Query the status of httpd service: systemctl status httpd.service 2. Query whether the httpd service is started at boot: systemctl is-enabled httpd.service 3. Set the httpd service to start at boot: systemctl enable httpd.service 4. Set the httpd service to not start at boot: systemctl disable httpd.service

After completing the above operations, you can perform git operations on the external network, such as clone

git clone http://windows_IP_address/git/share.git

7. Access the above Git service from Android terminal

Pocket Git is recommended

Download address:

Link: https://pan.baidu.com/s/1JAUsvU-qKAg-7FJGWv2JSA

Extraction code: 9cgu

So far, we have built a Git service based on the http protocol, and used Pocket Git to transfer files between Android and centOS 8 on the computer.

Summarize

The above is the method introduced by the editor to build Git service based on http protocol on VMware+centOS 8. I hope it will be helpful to everyone!

You may also be interested in:
  • Using SpringBoot+OkHttp+fastjson to implement Github's OAuth third-party login
  • How to connect to git using https in Linux without entering a password every time

<<:  Complete step record of Vue encapsulation of general table components

>>:  Detailed graphic tutorial on how to install the unzipped version of MySQL under Windows 10

Blog    

Recommend

Detailed explanation of the use of base tag in HTML

In requireJS, there is a property called baseURL....

How to install Nginx in CentOS7 and configure automatic startup

1. Download the installation package from the off...

Detailed explanation of how to customize the style of CSS scroll bars

This article introduces the CSS scrollbar selecto...

Comprehensive understanding of HTML Form elements

As shown below: XML/HTML CodeCopy content to clip...

Summary of MySQL usage specifications

1. InnoDB storage engine must be used It has bett...

Sharing tips on using vue element and nuxt

1. Element time selection submission format conve...

Detailed explanation of the difference between var, let and const in JavaScript

Table of contents As a global variable Variable H...

A method of making carousel images with CSS3

Slideshows are often seen on web pages. They have...

Solution for installing opencv 3.2.0 in Ubuntu 18.04

Download opencv.zip Install the dependencies ahea...

Using MySQL in Windows: Implementing Automatic Scheduled Backups

1. Write a backup script rem auther:www.yumi-info...

How to install and configure GitLab on Ubuntu 20.04

introduce GitLab CE or Community Edition is an op...

Summary of 9 excellent code comparison tools recommended under Linux

When we write code, we often need to know the dif...

Complete steps to configure a static IP address for a Linux virtual machine

Preface In many cases, we will use virtual machin...