Git
Create a git server
- apt-get install git
- adduser git
- Become the git user and add team's ssh keys to /home/git/.ssh/authorized_keys
- Change the git user's shell in /etc/passwd to /usr/bin/git-shell or to whichever path it is otherwise located
- mkdir /opt/git
- chown -Rv git.git /opt/git
- chmod -Rv g+ws /opt/git
- cd /opt/git
- mkdir myproject.git
- cd myproject.git
- git init --bare --shared
- See addition to /opt/git/myproject.git/config below
- mv /opt/git/myproject.git/hooks/post-update.sample /opt/git/myproject.git/hooks/post-update
- On your local computer do:
- mkdir ~/tmp
- cd ~/tmp
- git config --global user.name "Your Full Name"
- git config --global user.email your.name@abc.net
- git init
- git add .
- git commit -m 'initial commit'
- git remote add origin git@git.yourserver.com:/opt/git/myproject.git
- git push origin master
- NOTE: if you get an error that origin already exists, do "git remote rm origin" before push
- Debug the set up, this guide probably has a few mistakes
Add this to /opt/git/myproject.git/config
[http] receivepack = true
Add apache functionality
- apt-get install apache2
- addgroup www-data git
- a2enmod auth_basic
- a2enmod authnz_ldap
- Add virtual host definition below
- service apache2 restart
The virtual host file is something like this, but you need to fix the "XXXX" part, best luck:
<VirtualHost *:80> ServerName git.abc.net DocumentRoot /opt/git
ErrorLog ${APACHE_LOG_DIR}/git_error.log CustomLog ${APACHE_LOG_DIR}/git_access.log combined SetEnv GIT_PROJECT_ROOT /opt/git SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias / /usr/lib/git-core/git-http-backend/ AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /opt/git/$1 AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /opt/git/$1
ScriptAliasMatch \ "(?x)^/(.*/(HEAD | \ info/refs | \ objects/(info/[^/]+ | \ [0-9a-f]{2}/[0-9a-f]{38} | \ pack/pack-[0-9a-f]{40}\.(pack|idx)) | \ git-(upload|receive)-pack))$" \ /usr/lib/git-core/git-http-backend/$1
<LocationMatch ".*"> AuthType Basic AuthName "XXXX" AuthLDAPURL ldap://bananas:389/XXXX
AuthBasicProvider ldap
AuthLDAPBindDN "XXXX" AuthLDAPBindPassword XXXX
require valid-user </LocationMatch>
</VirtualHost>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.