Saya memiliki server CentOS 5 di domain.fr. Saya mencoba mengatur subdomain sehingga saya bisa menggunakannya dengan git, "git.domain.fr".
- Gudang saya ada di
/home/git
(contoh/home/git/repos.git
). - Saya sudah menginstal
git-http-backend and nginx
. - Saya telah menetapkan repositori seperti ini:
cd /home/git/repos.git && git --bare init
. - Saya sudah mengatur
git.conf
(termasuk dalamnginx.conf
) seperti di bawah ini.
Namun, pada shell klien saya, saya mendapatkan kesalahan fatal "repositori tidak ditemukan":
$ git clone http://git.domain.fr/repos.git
Adakah yang tahu apa yang harus saya lakukan? Tampaknya sangat sederhana, saya merasa frustrasi karena saya yakin itu bukan apa-apa ...
server {
listen 80;
server_name git.domain.fr;
root /home/git;
location ~ /(/.*) {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/bin/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL true;
fastcgi_param GIT_PROJECT_ROOT /home/git;
fastcgi_param PATH_INFO $1;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
}
EDIT # 1
Saya telah memperbarui file ini:
server {
listen 80;
server_name git.domain.fr;
root /home/git;
access_log /var/log/httpd/git.access.log;
error_log /var/log/httpd/git.error.log;
location / {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/bin/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL true;
fastcgi_param GIT_PROJECT_ROOT /home/git;
fastcgi_param PATH_INFO $uri;
fastcgi_pass unix:/usr/local/src/fcgiwrap/systemd/fcgiwrap.socket;
}
}
Saya juga memeriksa lokasi soket dan memberikannya kepada nginx:nginx
, tapi sekarang saya mendapatkan "Kesalahan 500".
$ git clone git.domain.fr/repos.git
Cloning into 'repos'...
fatal: unable to access 'git.domain.fr/repos.git/': The requested URL returned error: 500
bungkus fcgi sedang berjalan:
$ netstat -anp | grep cgi
unix 2 [ ACC ] STREAM LISTENING 1510861 24878/fcgiwrap /usr/local/src/fcgiwrap/systemd/fcgiwrap.socket
Ini memiliki izin yang benar:
$ ls -lia /usr/local/src/fcgiwrap/systemd/fcgiwrap.socket
3067341 srwxrwxrwx 1 nginx nginx 0 févr. 22 23:51 /usr/local/src/fcgiwrap/systemd/fcgiwrap.socket
git.error.log
kosong, tapi git.access.log
mengandung:
1**.***.***.*** - - [23/Feb/2014:13:02:17 +0100] "GET /repos.git/info/refs?service=git-upload-pack HTTP/1.1" 500 5 "-" "git/1.8.4"
EDIT # 2
Masalah hampir terpecahkan: Saya baru saja me-restart server saya untuk beberapa alasan, lalu git pull
bekerja.
Sekarang, saya mendapatkan kesalahan 403 ketika saya mendorong.
Dorong :
$ GIT_CURL_VERBOSE=1 git push origin master
* Adding handle: conn: 0x7fe329811800
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fe329811800) send_pipe: 1, recv_pipe: 0
* About to connect() to git.domain.fr port 80 (#0)
* Trying 108.162.199.22...
* Connected to git.domain.fr (108.162.199.22) port 80 (#0)
> GET /repos.git/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.8.4
Host: git.domain.fr
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache
< HTTP/1.1 403 Forbidden
* Server cloudflare-nginx is not blacklisted
< Server: cloudflare-nginx
< Date: Sun, 23 Feb 2014 18:20:59 GMT
< Content-Type: application/octet-stream
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: __cfduid=dc7d61cac342494e2b1307f88f8bf440f1393179659791; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.domain.fr; HttpOnly
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< CF-RAY: 1015eee9b29a091a-CDG
<
* Connection #0 to host git.domain.fr left intact
fatal: unable to access 'http://git.domain.fr/repos.git/': The requested URL returned error: 403
Tarik :
$ GIT_CURL_VERBOSE=1 git pull origin master
* Adding handle: conn: 0x7fb11b811800
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fb11b811800) send_pipe: 1, recv_pipe: 0
* About to connect() to git.domain.fr port 80 (#0)
* Trying 108.162.198.22...
* Connected to git.domain.fr (108.162.198.22) port 80 (#0)
> GET /repos.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.4
Host: git.domain.fr
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache
< HTTP/1.1 200 OK
* Server cloudflare-nginx is not blacklisted
< Server: cloudflare-nginx
< Date: Sun, 23 Feb 2014 18:25:33 GMT
< Content-Type: application/x-git-upload-pack-advertisement
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: __cfduid=d75ab90529a399f012383cdee482bc7ed1393179933224; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.domain.fr; HttpOnly
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< CF-RAY: 1015f596a8700914-CDG
<
* Connection #0 to host git.domain.fr left intact
From http://git.domain.fr/repos
* branch master -> FETCH_HEAD
Already up-to-date.
Log (error.log kosong):
$ tail -f /var/log/httpd/git.access.log
1**.***.***.*** - - [23/Feb/2014:19:20:59 +0100] "GET /repos.git/info/refs?service=git-receive-pack HTTP/1.1" 403 5 "-" "git/1.8.4"
1**.***.***.*** - - [23/Feb/2014:19:25:33 +0100] "GET /repos.git/info/refs?service=git-upload-pack HTTP/1.1" 200 294 "-" "git/1.8.4"
Saya memeriksa hak dan pemiliknya. Apa yang dapat saya ? Ada ide ?
EDIT # 3
SUKSES!
Git push mendapat 403 kesalahan saat Anda menggunakannya tanpa otentikasi. Saya hanya perlu mengatur nginx sehingga meminta pengguna / kata sandi:
server {
listen 80;
server_name git.domain.fr;
root /home/git;
access_log /var/log/httpd/git.access.log;
error_log /var/log/httpd/git.error.log;
auth_basic "Accès restreint";
auth_basic_user_file /home/domain.fr/git_access;
location / {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/bin/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL true;
fastcgi_param GIT_PROJECT_ROOT /home/git;
fastcgi_param PATH_INFO $uri;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/usr/local/src/fcgiwrap/systemd/fcgiwrap.socket;
}
}
Anda juga harus memeriksa apakah repositori Anda milik git:git
:
chmod -R g+ws repos.git
chgrp -R git repos.git
Semuanya baik-baik saja sekarang.
Terima kasih atas bantuan Anda !
chmod
danchgrp
perintah sangat penting.