Centos7 way to build http server apache + git git

Use apache and git

The first step, install httpd and git

yum install git httpd

The second step to start the httpd service

systemctl start httpd.service

The third step is to modify firewalld configuration file and restart firewalld

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

The fourth step is to create a git repository

mkdir -p /opt/http_git/test.git
cd /opt/http_git/test.git
git init --bare

// Set permissions 
chown -R & lt Apache: Apache / opt / http_git

The fifth step, create an account

// testuser for the account name can define 
htpasswd -m -c /etc/httpd/conf.d/git- team.htpasswd testuser
 
// modify the git-team.htpasswd file owner and their group 
chown the Apache: the Apache /etc/httpd/conf.d/git- team.htpasswd
 
// set the git-team.htpasswd file access permissions 
chmod  640 /etc/httpd/conf.d/git-team.htpasswd

A sixth step, provided Apache , it forwards the request to Git-CGI :

we / etc / httpd / conf / httpd.conf
 
// In the last line IncludeOptional conf.d / * add the above conf following contents: 
<VirtualHost *: 80 > 
        ServerName 192.168 . 1.55
        SetEnv GIT_HTTP_EXPORT_ALL
        SetEnv GIT_PROJECT_ROOT /opt/http_git
        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>
 
///
 ServerName is the domain name git server, where you fill in the last machine's IP
 / opt / http_git is the code to put the inventory folder
Will be ScriptAlias / git / access path is mapped to the beginning of the CGI program git-http- git backend
AuthUserFile is to verify that the user account file

Seventh step, restart httpd

systemctl restart httpd.service

Then you can clone a

git clone http://server/git/test.git

How to appear push if permission is prohibited and needs to close selinux

// Check selinux state 
getenforce

// temporary closure SELinux 
setenforce 0

// permanently closed SELinux 
VI / etc / sysconfig / SELinux
 // will SELINUX = enforcing = Disabled to the SELINUX
 // restart the server to

 

Guess you like

Origin www.cnblogs.com/Tsubasa0769/p/11625599.html