在 debian(基于系统)上为 git-http-backend 配置 nginx

Mar*_*sch 6 http nginx git

我在 Ubuntu 13.04 机器上使用 nginx 服务器无法让 git-http-backend 工作。之前在 Debian 7 上试过,但结果相似。基本上我遵循了http://weininger.net/configuration-of-nginx-for-gitweb-and-git-http-backend/但忽略了与 gitweb 相关的任何内容。

我做了以下事情:

使用以下命令安装 nginx、git、git-core 和 fcgiwrap:

apt-get install git git-core nginx fcgiwrap
Run Code Online (Sandbox Code Playgroud)

在 /var/git/test.git 上创建了一个裸仓库,并将其添加到 www-data:

mkdir -p /var/git/test.git
cd /var/git/test.git
git init --bare
git update-server-info
chown -R www-data:www-data /var/git
Run Code Online (Sandbox Code Playgroud)

将 /etc/nginx/sites-enabled/default 替换为

server {
        listen 80;

        server_name localhost;

        location / {
                root /var/git;

                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                fastcgi_param SCRIPT_FILENAME   /usr/lib/git-core/git-http-backend;
                fastcgi_param PATH_INFO         $uri;
                fastcgi_param GIT_PROJECT_ROOT  /var/git;
                fastcgi_param GIT_HTTP_EXPORT_ALL "";
                include /etc/nginx/fastcgi_params;
        }
}
Run Code Online (Sandbox Code Playgroud)

做的时候

GIT_CURL_VERBOSE=1 git clone http://localhost/test.git
Run Code Online (Sandbox Code Playgroud)

它打印:

Klone nach 'test'...
* Couldn't find host localhost in the .netrc file; using defaults
* About to connect() to localhost port 80 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /test.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.1.2
Host: localhost
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

* The requested URL returned error: 500 Internal Server Error
* Closing connection 0
error: The requested URL returned error: 500 Internal Server Error while accessing http://localhost/test.git/info/refs?service=git-upload-pack
fatal: HTTP request failed
Run Code Online (Sandbox Code Playgroud)

/var/log/nginx/error.log 不包含此请求的任何条目。我不确定 git-http-backend 是否写了一个日志文件但找不到一个。

你知道这个设置有什么问题吗?您知道获取有关 500 错误的更多信息/日志记录的方法吗?

jsh*_*awl 1

由于您收到 500 错误:

500 Internal Server Error while accessing http://localhost/test.git/info/refs?service=git-upload-pack
Run Code Online (Sandbox Code Playgroud)

尝试在 Web 浏览器中访问该地址,同时查看 nginx 错误日志。您可以通过以下方式“交互式”查看错误日志:

tail -f /var/log/nginx/error.log
Run Code Online (Sandbox Code Playgroud)

  • 如上所述,nginx 错误日志不显示任何信息。我假设错误发生在 git-http-backend 而不是 nginx 本身。 (3认同)