我使用FastCGI为Nginx上的Git服务器设置了所有必需的组件,并遵循几个教程的结合build议,最终完成此configuration:
server { listen 80; listen [::]:80; server_name example.com www.example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; root /path/to/site; index index.html; server_name example.com www.example.com; # ... Some ssl stuff here ... location ~ /git(/.*) { auth_basic "Access denied"; auth_basic_user_file /path/to/auth; client_max_body_size 0; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; include fastcgi_params; fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param GIT_PROJECT_ROOT /path/to/site/git; fastcgi_param PATH_INFO $1; fastcgi_param REMOTE_USER $remote_user; fastcgi_pass unix:/var/run/fcgiwrap.socket; } }
然而,使用窗口git客户端,尝试对https://example.com/git/test.git中find的存储库执行任何操作,都会导致客户端发生以下错误:
fatal: repository 'https://example.com/git/test.git/' not found
而在服务器上的这个错误:
2016/01/07 16:59:05 [error] 5155#0: *579 FastCGI sent in stderr: "Not a git repository: '/path/to/site/git/test.git'" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /git/test.git/info/refs?service=git-receive-pack HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "example.com"
这很奇怪,因为在/git/test.git文件夹中,我以前运行过git init --bare命令,因此存储库肯定存在。 我也试过chmod 0777 test.git -R ,以防万一它无法读取存储库或其他东西,但没有任何效果。
我已经尝试了许多相同的configuration变体,但我不明白这里出了什么问题,所以任何帮助将不胜感激。