Ubuntu 下 Git 服务器的安装和初级配置
操作環境:Ubuntu 10.04 LTS
安裝前提條件,已經安裝 apache 服務器或者同類服務器、openssh-service,并且已經熟悉使用 Git 客戶端
----- 安裝 Git ----------------------------------------------------------------------------------------------------------------------------------------------------------------
-----?安裝 gitosis?-----------------------------------------------------------------------------------------------------------------------------------------------------------
注:Gitosis 是方便通過 Git 與 ssh 架設中央服務器的軟件。
更詳細步驟參見:http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
安裝 python setuptools,為安裝 gitosis 做準備
安裝 Gitosis
注:將 Gitosis 的安裝文件暫存在 tmp 目錄下,安裝完成后可以自行刪除
增加名為 Git 的用戶,命令行禁用密碼
上傳公鑰到 tmp 目錄下(如果沒有,用本機上用 ssh-keygen -t rsa 生成,如何生成參見 Git 客戶端的使用方法)
注:上傳密鑰文件可以通過命令行上傳,也可以直接 FTP 上傳
運行命令
For good measure, let's make sure the post-update hook is set executable. I've seen it where sometimes it doesn't get set (problem with older setuptools):
安裝完成,現在把 gitosis-admin.git 拷到本地進行修改
gitosis-admin.git
sudo git clone git@YOUR_SERVER:gitosis-admin.git注:如果要求輸入密碼,則到服務器端為用戶 git 設置密碼(pssswd git)
注:如果出現錯誤 fatal: '~/gitosis-admin.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly,則改成 sudo git clone git@YOUR_SERVER:/home/git/repositories/gitosis-admin.git,即 gitosis-admin.git 所在位置
-----?配置 gitosis?---------------------------------------------------------------------------------------------------------------------------------------------------------------------
將 gitosis-admin.git clone 到本地后,對文件 gitosis.conf 進行相關配置。
文件說明:gitosis-admin 組成員有 useremail、another,該組對 gitosis-admin 倉庫有讀寫權限。writable 對應的為項目名稱,組名也為項目名稱。
添加用戶:
需要添加的用戶在本地生成密鑰(ssh-keygen -t rsa),然后將密鑰放在本地項目 gitosis-admin 的 keydir 文件夾內。
配置完成后,將文件推送到服務器 git 項目倉庫,然后配置更新。
-----?安裝配置 gitweb?----------------------------------------------------------------------------------------------------------------------------------------------------------------
安裝前提,需要已經安裝 apahce 或者同類的服務器軟件
1. 安裝gitweb
2. 配置gitweb
(1) 默認沒有 css 加載,把 gitweb 要用的靜態文件連接到 WebRoot 下:
注:注意后面的點
(2) 修改配置:
將 $projectroot 改為gitosis-admin.git所在目錄: /home/git/repositories
(3) 修改 /home/git/repositories權限,默認情況下,gitosis將 repositories權限設置為不可讀的
更詳細步驟參見:http://blog.enjoyrails.com/2009/01/06/git%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%AE%89%E8%A3%85/
----- 測試::上傳本地代碼到服務器 git 倉庫?-------------------------------------------------------------------------------------------------------------------------------------------
創建測試項目(服務器端)
注:如果項目文件夾沒有設置為最高權限,鍵入如下代碼否則在本地 push 代碼的時候會出現錯誤。
sudo chmod 777 -R /home/git/repositories/testproject.git push 本地項目(本機)
切換到項目目錄(使用 Windows 平臺下 Git Bash 命令行工具)
操作順利的話,gitweb 上可以看見已經 push 上去的項目了。
參考:
http://blog.csdn.net/ice520301/article/details/6142503
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
http://www.enjoyrails.com/wikis/Git%E5%AE%89%E8%A3%85
http://blog.enjoyrails.com/2009/01/06/git%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%AE%89%E8%A3%85/
http://www.stylejar.com/archives/ubuntu_install_git_server.html
轉載于:https://www.cnblogs.com/shamrocker/archive/2012/08/15/2639477.html
總結
以上是生活随笔為你收集整理的Ubuntu 下 Git 服务器的安装和初级配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 了解keycode
- 下一篇: Android中Bitmap和Drawa