Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git-http-backend with apache2.4 Centos 7

I try to set up a Git-server on my apache server but it dont work! I got the following git.conf

SetEnv GIT_PROJECT_ROOT /var/www/html/git/project1
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

<Directory "/var/www/html/git/project1">
   Options ExecCGI Indexes
   Require all granted
</Directory>

<LocationMatch "^/git/.*/git-receive-pack$">
   AuthType Basic
   AuthName "Git Access"
   AuthUserFile /var/www/html/git/users/.htpasswd
   Require valid-user
</LocationMatch>

I created a user but I cant acces the site.

Forbidden

You don't have permission to access /git/ on this server.

If I comment line 3

#ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

Now I can acces the site and can see the git repository. Does anyone know how I can fix this. English isn't my first language so please be patient with my text. Thanks for reading best regards Sam

like image 765
SamuelTJackson Avatar asked Mar 04 '26 20:03

SamuelTJackson


1 Answers

Following git http-backend doc:

SetEnv GIT_PROJECT_ROOT /var/www/git

This should be the root folder under which you have git repos (repo1.git, repo2.git, ...). It should not be /git/project1, which looks like the name of a repo itself.

So try the example:

SetEnv GIT_PROJECT_ROOT /var/www/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

<LocationMatch "^/git/.*/git-receive-pack$">
    AuthType Basic
    AuthName "Git Access"
    Require group committers
    ...
</LocationMatch>

Note: after an interactive session, it turns out you need to be sure that:

  • the data read or served by apache are owned by apache:apache (chown -R)
  • SElinux (Security-Enhanced Linux) allows the httpd service to read Z: ls -Z

If the later point does not include httd_rw, you need to type (as in "How come my Apache can only access root owned files?"), to change its context:

chcon -vR --type=httpd_sys_content_t /html/
like image 98
VonC Avatar answered Mar 06 '26 10:03

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!