Difference between revisions of "Setup git over HTTP server"
m |
|||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[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 | ||
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 | |||
</LocationMatch> | </LocationMatch> | ||
</pre> | </pre> | ||
Line 63: | Line 63: | ||
password <http_password> | password <http_password> | ||
</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://<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: | |||
# 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 | |||
[[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:
- Install package git
- Choose a base folder for all git repositories, for example, '/var/www/git'
- 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/
- 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
- Now users can clone test repository using:
- git clone http://<server_ip_or_name>/git/test
- 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:
- 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:
- #!/bin/sh
- git-commit-notifier path_to_config.yml
- 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
Home > CentOS > CentOS 6.x > Versioning tools > git > Setup git over HTTP server