apache - How to set up git over http? -
I need to install a git server with git-over-http (smart http), but there are resources available online Dirt, mixing in other Apache configurations, details are missing or not being sufficiently clear.
Based on the lack of available resources, I am answering this question myself.
First it is necessary to understand that there are 2 components for git-over-http: git and apache. These two challenges to configure the interface between these two components with names connected via a script git-http-backend, which is forwarded by Apache requests Jiaiti.
Note: Security is outside the scope of this guide.
Start by installing git and apache2 using your distribution package manager.
Add the necessary modules by Epache to enable Git-Over-http These cgi alias and env
$ a2enmod cgi aka env
- copy
& lt; VirtualHost *: 80 & gt; . Setenv GIT_PROJECT_ROOT / data / Git setenv GIT_HTTP_EXPORT_ALL setenv REMOTE_USER = $ REDIRECT_REMOTE_USER ScriptAliasMatch \ "(? X) ^ / (* / (head | \ info / refs | \ / objects (information / [^ /] + | \ [0- 9 A-F] {2} / [0-9A-F] {38} | \ Pack / Pack- [0- 9A-F] {40}. (Pack | IDX) | \ git- (Upload Get | -pack)) $ "\" / usr / lib / git / git-http-backend / $ 1 "alias / git / data / git & lt; Directory / usr / lib / git & gt; Option + ExecCGI -MultiViews + SymLinksIfOwnerMatch Allow overrides Do not allow any command, Allow all from & lt; / Directory & gt; & Lt; / VirtualHost & gt;
- Now replace the 2 events of
/ data / git
with the parent directory of your git repos (don ' If you do not have a repo yet, just use that directory where you intend to keep it.
In addition to
/ usr / lib / git / git- Http- backend
with the git-http-backend service on your system, the$ find / -name git-http-backend
Can be found by using
REDIRECT_REM on your system OTE_USER
actually overwrites a validREMOTE_USER
. If this setup does not work when it finishes, try deleting the line.According to the source, the directory given by
can be necessary to replace the last two lines within . For Apache 2.4 < / Strong> and above
- Restart Apache server:
$ apache2ctl -k beautiful
now Apache server has been set up, but we have not done so yet, there are some important parts to setting up a repo that will affect whether this setup works or not .
$ mkdir myrepo.git $ cd myrepo.git $ Git init: = "6">
- Set Repo --bare --shared $ sup Hooks / Reply update.sample hook / reply updated $ git update-server-info $ chown r wwwrun: www
here It is important to understand that in the last line, the owner of the repo turns into a 2 user in an appetite. This user may be different on your system to find Apache user,
$ ps aux | Execute Egrep '(Apache | httpd)' '
. To then find the name of the user's group, execute the$ id username
. Change the user according to wwwrun and group www on my system.- Use repo
To use a repo, you need to know the URL. The URL for this setup is
Note: http s will not work.
When you reach a customer to repo, if you add it as a remote:
$ git remote Add original http: //server.domain/myrepo.git
Then you can chat with it like any other GIT repo.
- Now replace the 2 events of
Comments
Post a Comment