Git: Setting up private server on CentOS via HTTP using git-http-backend
1. Install git and apache
Open terminal and run commands:$yum install httpd gitStart apache
$apachectl start
2. Create users file
/etc/git-usersusername:password othername:otherpassword
If you don't know how to create that file then install nano editor:$yum install nanoand create file$nano /etc/git-usersenter content and press Ctr + O to save, Ctr + X to exit.
3. Create folder that you want to push git base in
$mkdir /var/www/git
4. Create apache config file
/etc/httpd/conf.d/git.conf
SetEnv GIT_PROJECT_ROOT /var/www/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} /git-receive-pack$
RewriteRule ^/git/ - [E=AUTHREQUIRED:yes]
<LocationMatch "/git">
Order Deny,Allow
Deny from env=AUTHREQUIRED
AuthType Basic
AuthName "Git Access"
AuthUserFile /etc/git-users
Require valid-user
</LocationMatch>
If you don't know how to find apache config folder, use this commandRestart apache$apachectl -VFor example we found that apache config file in/etc/httpd/conf/httpd.confthen we create file/etc/httpd/conf.d/git.conf
$apachectl restart
5. Create git base
$cd /var/www/git # folder that we created in step 3 $mkdir test.git $cd test.git $git init --bare --sharedOpen config file
/var/www/git/test.git/config in git base then add this
[http] receivepack = true
6. Using
Access git server viahttp://your_server_ip_address/git/test.git with username and password set at step 2.
By
minhbkpro
|
Wednesday, 15 February 2017
|
Apache
,
Git
|
0 Comments
Read More ...