【问题标题】:Git + Smart Http(s): 403 ErrorGit + 智能 Http(s): 403 错误
【发布时间】:2017-02-03 16:03:19
【问题描述】:

虽然看了很多帖子,还是没能解决这个问题。
我想使用 Git + Smart Http,在我的树莓派上使用远程存储库。
我在 Arch Linux 上运行。
首先,为了简单起见,让我们考虑一个 Http 配置(而不是 https)。
我的树莓派上正确安装了 Apache 和 Git,并且 Http 连接的端口是 8080。

在我的树莓派上:

1. 我在 /etc/httpd/conf/http.conf 中取消了关于 mod_cgi、mod_alias 和 mod_env 的行的注释

2. 我在 /etc/httpd/conf/http.conf 中添加了以下几行:

SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/

<Directory "/usr/lib/git-core*">
    Require all granted
</Directory>
  1. 我已经创建了目录 /srv/git

    # mkdir -p /srv/git
  2. 我已经创建并初始化了一个 git 存储库:

    # mkdir -p /srv/git/test.git
    # git init --bare
  3. 我已经更改了 repo 的所有者和组:

    # chown -R http:http /srv/git/test.git

在我的客户端上:

  1. 我已经在文件夹中克隆了 repo

    $ git clone @987654321@
  2. 我已经创建并添加了一个新文件并且我已经提交了

    $ nano test.c
    $ git add test.c
    $ git commit -m 'first' 
  3. 我已经在我的 Rasperry Pi 上推送了新项目

    $ git push origin master

但我有这个错误:

atal: unable to access 'address:8080/git/test.git/';: The requested URL returned error: 403

【问题讨论】:

  • 什么版本的 Apache 和 Git 在你的服务器(树莓派)上运行

标签: linux git apache repository smart-http


【解决方案1】:

如果你在测试文件夹(在其中初始化了一个 git repo)克隆 repo,这意味着你有:

test/test

如果您从第一个测试文件夹推送,则该 repo 将没有任何来源。

尝试删除任何测试文件夹,然后重新开始:

git clone http://address:8080/git/test.git
cd test
# work
git add .
git commit -m "work"
git push -u origin master

关于 403 错误,我建议在服务器 Apache (2.4) 端:

<Directory "/usr/lib/git-core*">
   Options ExecCGI Indexes
   Order allow,deny
   Allow from all
   Require all granted
</Directory>

还有:

<LocationMatch "^/.*/git-receive-pack$">
    Options +ExecCGI
    Require all granted
</LocationMatch>
<LocationMatch "^/.*/git-upload-pack$">
    Options +ExecCGI
    Require all granted
</LocationMatch>

另外,在服务器上,在 git bare repo 文件夹中:

cd /srv/git/test.git
git config --file config http.receivepack true

【讨论】:

  • 谢谢,新问题:致命:无法访问 'address:8080/git/test.git':请求的 URL 返回错误:403
  • @PenguinEngineer 你的服务器(树莓派)上运行的是什么版本的 Apache 和 Git?
  • PS:我已经编辑了最初的问题,现在它只出现了 403 错误
  • 使用 apachectl -V 命令:服务器版本:Apache/2.4.23 (Unix)
  • @PenguinEngineer 好的。还有 Git?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-11-21
  • 2016-12-23
  • 1970-01-01
  • 2011-07-12
  • 2016-04-05
  • 2013-01-02
  • 1970-01-01
相关资源
最近更新 更多