Assume SELinux is disabled on your Git server…
The following setup is on CentOS and assume your Git repositories are all located under /data/repos.
1. Install Git and Apache.
yum install git httpd
2. Create the /etc/httpd/conf.d/git.conf.
# Git over HTTP
<VirtualHost *:80>
SetEnv GIT_PROJECT_ROOT /data/repos
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
<Location /git/>
AuthType Basic
AuthName "Git Access"
AuthUserFile /var/www/passwd.git
Require valid-user
</Location>
</VirtualHost>
3. Create the /var/www/passwd.git.
htpasswd -c /var/www/passwd.git [username]
4. Restart Apache.
/etc/init.d/httpd restart
Verify if you could git clone and push any repository.
If you have SELinux, set the type as follow:
chcon -R -t httpd_git_rw_content_t /data/repos chcon -t httpd_git_script_exec_t /usr/libexec/git-core/git-http-backend
Done =)
Next: Git – Setup a bare repository which is writable by both user and group
Reference:

One thought on “Make Git work on HTTP protocol”