2016-12-02 152 views
2

我試圖用git -http-backend和apache建立一個git服務器2.4我發現this question關於同樣的東西,這對我很有幫助,但我仍然達到了一個地步我卡住了。用apache設置git-http-backend 2.4

我已經安裝在Ubuntu 16.04 Git和的Apache2和使用

sudo a2enmod cgi alias env

添加需要的模塊然後在/etc/apache2/apache2.conf添加下面的代碼片段:

<VirtualHost *:80> 
    SetEnv GIT_PROJECT_ROOT /var/www/git 
    SetEnv GIT_HTTP_EXPORT_ALL 
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER 
    ScriptAliasMatch \ 
     "(?x)^/(.*/(HEAD | \ 
      info/refs | \ 
      objects/(info/[^/]+ | \ 
      [0-9a-f]{2}/[0-9a-f]{38} | \ 
      pack/pack-[0-9a-f]{40}\.(pack|idx)) | \ 
      git-(upload|receive)-pack))$" \ 
     "/usr/lib/git-core/git-http-backend/$1" 
    Alias /git /var/www/git 
    <Directory /usr/lib/git-core> 
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
     AllowOverride None 
     Require all granted 
    </Directory> 
</VirtualHost> 

注意/var/www/git是我打算讓我的回購去,並運行

find/-name git-http-backend顯示/usr/lib/git-core/git-http-backend

接下來,/var/www/git/裏面我創建了一個目錄myrepo.git,並將它設置爲這樣:

sudo git init --bare --shared 
sudo cp hooks/post-update.sample hooks/post-update 
sudo git update-server-info 

接下來,我必須改變目錄apache2的所有者的所有權(IM告知)。運行ps aux | egrep '(apache|httpd)'返回如下:

root 3087 0.0 0.4 73688 4928 ? Ss 02:37 0:00 /usr/sbin/apache2 -k start 
www-data 3455 0.0 0.5 362836 5852 ? Sl 03:13 0:00 /usr/sbin/apache2 -k start 
www-data 3456 0.0 0.5 362836 5852 ? Sl 03:13 0:00 /usr/sbin/apache2 -k start 
git 3531 0.0 0.0 14512 932 pts/1 S+ 03:19 0:00 grep -E --color=auto (apache|httpd) 

現在我不知道,因爲它看起來既像rootwww-data正在運行的東西,但現在我已經決定設置所有權www數據(也許它應該是根?)。 www數據的組也是www數據(我認爲)

$ id www-data 
uid=33(www-data) gid=33(www-data) groups=33(www-data) 

,所以我用它來設置所有權:

sudo chown -R www-data:www-data . 

我還依稀記得閱讀整個路徑必須屬於Apache用戶所以只是好措施我設置

sudo chown -R www-data:www-data /var/www 

現在從我的LOCALMACHINE我試圖克隆myrepo:

git clone http://<ip-address>/myrepo.git 

而且我得到的錯誤:

fatal: unable to access 'http://<ip-address>/myrepo.git/': The requested URL returned error: 503 

任何人都可以看到什麼林做錯了什麼?

回答

0
Alias /git /var/www/git 

這應該意味着你的URL應該包括/混帳它:

git clone http://<ip-address>/git/myrepo.git 

我看不出在這個Apache configuration

+0

呀這樣的別名,我複製的別名從[這個答案](http://stackoverflow.com/a/26734934/3486338)林不知道這是必要的。我認爲主要問題是權限問題,但是我將目錄所有權更改爲'root',現在我可以克隆它,但我無法恢復。我認爲它類似於[這篇文章](http://stackoverflow.com/questions/6448242/git-push-error-insufficient-permission-for-adding-an-object-to-repository-datab) – bradimus