#
Because of the company's special needs, GIT needs to be integrated into the IBM RTC, and RTC uses HTTP, so you can only discard git native ssh and use smart Http,git server to build on the CentOS system. Bloggers in the browse n many tutorials found are relatively incomplete, and there is no special demand for smart HTTP, there is a relatively complete but also a few pits (Bo master to fill these pits spit a lot of old blood, so decided to take the tutorial to blog on the prevention of Rainy days, This tutorial is aimed at the developer of non-professional operations such as bloggers, please correct me! )
The following are the main environmental parameters
- System Linux CentOS 7
- git version 2.6.0.0
- Container Apache 2.6.4 (HTTPD)
1. First open the system terminal, get root operation permission (blogger is Xshell telnet):
输入命令:sudo su
The system requires the user password to be entered:
Complete the following entry as shown
2. Install httpd:
Input command: Yum install httpd (no special attention required except for the "Y" setting)
3. Install the Gitweb (if you do not need to install):
Input command: Yum install Gitweb
4. After completing the creation of a git repository, choose to create a bare repo in the/srv/directory (if different directories need to be modified in the configuration file mentioned later), named Test.git
Enter Command Cd/srv
Input command git init–bare test.git
5. Change the group of file owners in this directory to Apache
Input command: Chown-r apache:apache test.git
6. Modify the httpd configuration file with the Vim editor
Input command: vim/etc/httpd/conf/httpd.conf
Add the following configuration to the document:
# 设置git所管理的工程的存放目录SetEnv GIT_PROJECT_ROOT /srvSetEnv GIT_HTTP_EXPORT_ALL# 对git库的各种请求,执行git-http-backend.cgiScriptAliasMatch "(?x)^/git/(.*/(HEAD | info/refs | objects/(info/[^/]+ | [0-9a-f]{2}/[0-9a-f]{38} | pack/pack-[0-9a-f]{40}\.(pack|idx)) | git-(upload|receive)-pack))$" /usr/local/libexec/git-core/git-http-backend/$1ScriptAlias / /usr/share/gitweb/gitweb.cgi#为git的http操作添加认证,认证信息存在git-auth文件中,关于此文件的配#置将会在稍后讲解<Location /> AuthType Basic "Git Access" AuthUserFile /var/www/git-auth Require valid-user AuthBasicProvider file</Location>
Enter Wq save file after completion
7. Push's Operation Certification
A. Open the Test.git warehouse you just created to add the following configuration to Config
Input command: cd/srv/test.git/
B. Open the config file to add the following:
[HTTP]
Receivepack = True
Save and exit when finished
C. Add git-auth password file under the/var/www folder defined in the re-configuration file
Input command: cd/var/www
Add an account called Git (which you can define yourself)
Input command: htpasswd-c git-auth git
8. Restart the HTTPD service
Input command: Service httpd start
Clone and push check operations are done on the client after completion
(Note: If the system user does not have permissions, use the chmod 755-r username command to add permissions, otherwise the push will be rejected)
So far! Build finished, Bo Master did not configure Gitweb but the relevant tutorials are also many and relatively simple, the remaining problem is nothing more than the Linux group permissions problem, this view of the individual environment to do fine-tuning, if there are shortcomings also look at the generous enlighten! Reference Links:
Http://particle128.com/posts/2014/12/git-server.html
Https://git-scm.com/docs/git-http-backend
Https://git-scm.com/book/be/v2/Git-on-the-Server-Smart-HTTP
Build a smart HTTP-based git server in CentOS