Git服务器无法推送,无法创建临时对象目录

oxf4rvwz  于 2023-01-19  发布在  Git
关注(0)|答案(1)|浏览(150)

下午好,
我正在尝试创建自己的托管git服务器,但在配置git选项时遇到了麻烦。
我已经安装了nginx和fastcgi,下面是git文件的配置
文件/etc/nginx/nginx配置文件

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
}

http {
        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        server_tokens off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        gzip on;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        server {
                listen 80;
                listen [::]:80;

                return 301 https://$host$request_uri;
        }
}

/etc/nginx/站点可用/默认(链接到/etc/nginx/站点启用/默认)

server {
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;

        ssl_certificate /etc/letsencrypt/live/[redacted]/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/[redacted]/privkey.pem;

        root /var/www/html;
        server_name [redacted] www.[redacted];
}

/etc/nginx/可用站点/git(与之前相同,已链接)

git@localhost:/$ cat /etc/nginx/sites-available/git 
server {
        listen 443 ssl;
        listen [::]:443 ssl;

        ssl_certificate /etc/letsencrypt/live/[redacted]/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/[redacted]/privkey.pem;

    server_name git.[redacted];

    auth_basic "login";
    auth_basic_user_file "/var/www/html/git/.htpasswd";
    location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
        client_max_body_size 0;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
        fastcgi_param GIT_HTTP_EXPORT_ALL "";
        fastcgi_param GIT_PROJECT_ROOT /git;
        fastcgi_param REMOTE_USER $remote_user;
        fastcgi_param PATH_INFO $uri;
        fastcgi_pass  unix:/var/run/fcgiwrap.socket;
    }
}

每次我尝试提交时,我都得到:

error: remote unpack failed: unable to create temporary object directory
To https://git.[redacted]/[repo]
! [remote rejected] main -> main (unpacker error)
error: failed to push some refs to https://git.[redacted]/[repo]

分配git项目的目录完全由git用户拥有(这可能是问题所在吗)?

  • 多次重新启用这两种服务。
  • 重构/etc/nginx/sites-available/git和默认值。
  • 重置auth_basic的用户
  • 文件夹的所有权。
  • 换树枝。
qij5mzcb

qij5mzcb1#

自行解决:
将repo的所有权设为git:www-data正如@eftshift0指出的,或者至少是指导的,问题是谁在运行git进程,谁拥有repo的所有权!
因此,我将所有权更改为user:group corresponding。
谢谢!

相关问题