There is
already a bunch of posts about setting up Git over HTTP(S), but this one is
specificaly targeted at setting it up under CentOS as cleanly as possible.
There was bunch of errors that I saw along the way, so I will try to explain
the process step by step.
First, you
have to install Apache and Git.:
# yum -y install
httpd git
#
/etc/init.d/httpd start
Now, let’s
create directories for git and create our first repo:
# mkdir /var/www/html/gitrepos
# cd /var/www/html/gitrepos
# mkdir repo01
&& cd repo01
# git --bare init
# git
update-server-info
# cd /var/www/html
# chown -R
apache: gitrepos
We are
using ‘git –bare’, so that online repository doesn’t have files but only git
metadata. That will enable users to push directly to online repository,
otherwise they wouldn’t be able to push thier changes. This was the first error
I did, I created repo with ‘git init’ and was not able to push later. After the
repo is set up and chowned, lets set up apache.
This is my
configuration for vhost:
#
# vhost for git
repositories (http)
#
<VirtualHost
*:80>
ServerName git
DocumentRoot /var/www/html/gitrepos
<Location />
DAV on
# general auth settings
AuthName "Git login:"
AuthType Basic
# file authentication
AuthUserFile /var/www/html/.htpasswd
AuthGroupFile /var/www/html/.htgroup
<LimitExcept PROPFIND>
Require valid-user
</LimitExcept>
</Location>
<Location /repo01>
<LimitExcept PROPFIND>
</LimitExcept>
</Location>
LogLevel warn
ErrorLog /var/log/httpd/git_error.log
CustomLog /var/log/httpd/git_access.log
combined
</VirtualHost>
#
We can
fill up htpasswd file with – htpasswd command
# htpasswd -c /var/www/html/.htpasswd
user1
# htpasswd -c /var/www/html/.htpasswd
user2
# htpasswd -c /var/www/html/.htpasswd
user3
And
htgroup with:
# echo
"adminlinux: user1 user2" >> /var/www/html/.htgroup
Now, on
the client side, do a:
% git clone http://user1@git/repo01
After the
first change/commit you do, be careful when you push those changes for the
first time.
This is
the command I used for the first push:
% git push
--set-upstream origin master
And that’s
it!...
No comments:
Post a Comment