Setup procedure
Install git, this provides the git-http-backend. yum install git
Install httpd. yum install httpd
SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
<Files "git-http-backend">
AuthType Basic
AuthName "Git Access"
AuthUserFile /srv/git/.htpasswd
Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#)
Require valid-user
</Files>
Create the git root and configure the users
mkdir /srv/git
htpasswd -c /srv/git/.htpasswd db57
Test procedure
On the server:
cd /srv/git
mkdir my-test-repository
cd my-test-repository
git init --bare
chown -R apache:apache /srv/git
On a client:
mkdir my-test-repository
cd my-test-repository
git init
echo "test" > README.md
git add -A
git commit -m 'initial import'
git remote add origin http://localhost/git/my-test-repository
git push -u origin master
As far as I know, all repositories need to be created server-side before you are allowed to push to them.
From outside
Where the IP of your server is 10.179.127.226,
git clone http://10.179.127.226/git/my-test-repository
Cloning is unauthenticated, only push is authenticated.