Difference between revisions of "Setup git over HTTP server"

From Notes_Wiki
(Created page with "=Setup git over HTTP server= To setup git over HTTP server use following steps: #Install package git #Choose a base folder for all git repositories, for example, '<tt>/var/ww...")
 
m
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Setup git over HTTP server=
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Versioning tools]] > [[Git|git]] > [[Setup git over HTTP server]]


To setup git over HTTP server use following steps:
To setup git over HTTP server use following steps:
Line 12: Line 12:
#Use following steps to create a test repository
#Use following steps to create a test repository
#:<pre>
#:<pre>
#:: cd var/www
#:: cd /var/www
#:: mkdir git
#:: mkdir git
#:: cd git
#:: cd git
#:: mkdir test
#:: mkdir test
#:: cd test
#:: cd test
#:: git init --bare
#:: git init --bare --shared
#:: git config --file config http.receivepack true
#:: cd /var/www
#:: cd /var/www
#:: chown -R apache:apache git
#:: chown -R apache:apache git
Line 38: Line 39:
             Options all
             Options all
             Order deny,allow  
             Order deny,allow  
            Deny from All
             AuthType Basic
             AuthType Basic
             AuthName "Test1 git repository"
             AuthName "Test1 git repository"
Line 48: Line 48:
             Require ldap-group cn=admin,ou=groups,dc=virtual-labs,dc=ac,dc=in
             Require ldap-group cn=admin,ou=groups,dc=virtual-labs,dc=ac,dc=in
             Require ldap-attribute gidNumber=501
             Require ldap-attribute gidNumber=501
            Satisfy any
#            Satisfy any
   </LocationMatch>
   </LocationMatch>
</pre>
</pre>
This information is provided here for fast access. For detailed information on configuring LDAP authentication for apache refer to [[Configuring LDAP based authentication for apache]]




Line 61: Line 63:
password &lt;http_password&gt;
password &lt;http_password&gt;
</pre>
</pre>
Multiple machines can also be configured.  Please refer to http://stackoverflow.com/questions/4575312/how-do-i-add-multiple-accounts-machine-login-password-to-my-vim-netrc-file
After this use '<tt>git clone</tt>' or '<tt>git push</tt>' as usual for configured server and git will automatically use above configured authentication.  If permanent configuration is not desired then use git clone https://&lt;username&gt;@&lt;server&gt;/git/&lt;repository&gt; to make git prompt for password on command-line. 
==Configuring git-commit-notifier for git over http==
For configuring git-commit-notifier for git over http use following steps:
For installation use:
# yum -y install epel-release
# yum -y install rubygems ruby-devel rubygem-nokogiri gcc zlib-devel
# gem install git-commit-notifier
For configuration use:
# Go to git base folder and download config file from https://raw.githubusercontent.com/git-commit-notifier/git-commit-notifier/master/config/git-notifier-config.example.yml
# Edit config file to set "mailinglist:" value appropriately
# Verify by using simple mail command that outgoing mails work
# Go to repository/hooks folder
# Create a file named post-receive with following contents:
#:<pre>
#::    #!/bin/sh
#::    git-commit-notifier path_to_config.yml
#:</pre>
# Set execute permissions on file
# Try to push something new and see if mail is being sent
Steps learned from https://github.com/git-commit-notifier/git-commit-notifier


After this use '<tt>git clone</tt>' or '<tt>git push</tt>' as usual for configured server and git will automatically use above configured authentication.
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Versioning tools]] > [[Git|git]] > [[Setup git over HTTP server]]

Latest revision as of 15:42, 24 August 2022

Home > CentOS > CentOS 6.x > Versioning tools > git > Setup git over HTTP server

To setup git over HTTP server use following steps:

  1. Install package git
  2. Choose a base folder for all git repositories, for example, '/var/www/git'
  3. Configure '/etc/httpd/conf/httpd.conf' virtual host for git using:
    SetEnv GIT_PROJECT_ROOT /var/www/git
    SetEnv GIT_HTTP_EXPORT_ALL
    ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
  4. Use following steps to create a test repository
    cd /var/www
    mkdir git
    cd git
    mkdir test
    cd test
    git init --bare --shared
    git config --file config http.receivepack true
    cd /var/www
    chown -R apache:apache git
  5. Now users can clone test repository using:
    git clone http://<server_ip_or_name>/git/test
  6. One changes are done locally they can be pushed to server using:
    git push origin master


Configuring HTTP authentication for repository on server

To configure HTTP authentication for repository on server use steps mentioned at Configuring LDAP based authentication for apache. Note that for git repository the authentication configuration should be done with LocationMatch for URLs starting with "/git/<repository_name>". For example to enable authentication for test repository created above use:

  <LocationMatch "^/git/test.*$">
            Options all
            Order deny,allow 
            AuthType Basic
            AuthName "Test1 git repository"
            AuthBasicProvider ldap
            AuthzLDAPAuthoritative on
            AuthLDAPURL ldap://ldap.virtual-labs.ac.in:389/ou=people,dc=virtual-labs,dc=ac,dc=in?uid 
            AuthLDAPGroupAttribute memberUid
            AuthLDAPGroupAttributeIsDN off
            Require ldap-group cn=admin,ou=groups,dc=virtual-labs,dc=ac,dc=in
            Require ldap-attribute gidNumber=501
#            Satisfy any
   </LocationMatch>

This information is provided here for fast access. For detailed information on configuring LDAP authentication for apache refer to Configuring LDAP based authentication for apache


Configuring HTTP authentication on client

To configure HTTP authentication for git on client create a file '.netrc' in users home folder with following details:

machine <server_name_or_ip>
login <http_username>
password <http_password>

Multiple machines can also be configured. Please refer to http://stackoverflow.com/questions/4575312/how-do-i-add-multiple-accounts-machine-login-password-to-my-vim-netrc-file

After this use 'git clone' or 'git push' as usual for configured server and git will automatically use above configured authentication. If permanent configuration is not desired then use git clone https://<username>@<server>/git/<repository> to make git prompt for password on command-line.


Configuring git-commit-notifier for git over http

For configuring git-commit-notifier for git over http use following steps:

For installation use:

  1. yum -y install epel-release
  2. yum -y install rubygems ruby-devel rubygem-nokogiri gcc zlib-devel
  3. gem install git-commit-notifier

For configuration use:

  1. Go to git base folder and download config file from https://raw.githubusercontent.com/git-commit-notifier/git-commit-notifier/master/config/git-notifier-config.example.yml
  2. Edit config file to set "mailinglist:" value appropriately
  3. Verify by using simple mail command that outgoing mails work
  4. Go to repository/hooks folder
  5. Create a file named post-receive with following contents:
    #!/bin/sh
    git-commit-notifier path_to_config.yml
  6. Set execute permissions on file
  7. Try to push something new and see if mail is being sent

Steps learned from https://github.com/git-commit-notifier/git-commit-notifier


Home > CentOS > CentOS 6.x > Versioning tools > git > Setup git over HTTP server