Make Git work on HTTP protocol

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
  ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

  <Location /git/>
    AuthType Basic
    AuthName "Git Access"
    AuthUserFile /var/www/passwd.git
    Require valid-user


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



One thought on “Make Git work on HTTP protocol”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.