jasmine214--love

          只有當你的內(nèi)心總是充滿快樂、美好的愿望和寧靜時,你才能擁有強壯的體魄和明朗、快樂或者寧靜的面容。
          posts - 731, comments - 60, trackbacks - 0, articles - 0

          1. 準備環(huán)境,安裝更新

          1sudo apt-get update 
          2sudo apt-get upgrade

          2. 安裝 openssh服務(wù)器

          1sudo apt-get install openssh-server openssh-client

          3. 安裝 git服務(wù)器

          1sudo apt-get install git-core

          4. 配置 git服務(wù)器

          • 創(chuàng)建git服務(wù)器管理用戶

            1sudo useradd -m git
            2sudo passwd git

          用戶名和密碼均為git

          • 創(chuàng)建git倉庫存儲目錄

            1sudo mkdir /home/git/repositories
          • 設(shè)置git倉庫權(quán)限

            1sudo chown git:git /home/git/repositories
            2sudo chmod 755 /home/git/repositories
          • 初始化全局設(shè)置

            1git config --global user.name "myname"
            2git config --global user.email "myname@server"

          5. 安裝python的setup tool

          1sudo apt-get install python-setuptools

          6. 獲取并安裝gitosis

          1cd /tmp
          2git clone https://github.com/res0nat0r/gitosis.git
          3cd gitosis
          4sudo python setup.py install

          7. 配置gitosis

          1cp ~/.ssh/id_rsa.pub /tmp
          2sudo -H -u git gitosis-init < /tmp/id_rsa.pub
          3sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

          8.創(chuàng)建個人公鑰和私鑰,另外一臺pc機(git客戶端)

          • 在默認用戶的主目錄路徑下,運行以下命令,按照提示創(chuàng)建公鑰和私鑰

            1ssh-keygen -t rsa
          • 默認情況下,公鑰和私鑰會保存在~/.ssh目錄下,如下所示:

            1id_rsa  id_rsa.pub  known_hosts

          9. 管理gitosis配置

          • 在git客戶端

            1cd ~
            2git clone git@hostname:用戶名/gitosis-admin.git
            3cd gitosis-admin/
          • 各個用戶按照前面提到的辦法生成各自的ssh公鑰文件后,服務(wù)器管理員把所有人的 ssh公鑰文件都拿來,拷貝到keydir目錄下。修改gitosis.conf文件,如下所示

            01[gitosis]
            02 
            03[group gitosis-admin]
            04writable = gitosis-admin
            05members = a@server1
            06 
            07[group developers]
            08writable = helloworld
            09members = a@server1 b@server2
            10 
            11[group test]
            12readonly = helloworld
            13members = c@server3
          • 這個配置文件表達了如下含義:gitosis-admin組成員有a,該組對gitosis-admin倉庫有讀寫權(quán)限; developers組有a,b兩個成員,該組對helloworld倉庫有讀寫權(quán)限; test組有c一個成員,對helloworld倉庫有只讀權(quán)限。 當然目前這些配置文件的修改只是在你的本地,你必須推送到gitserver上才能真正生效。 加入新文件、提交并push到git服務(wù)器:

            1git add .
            2git commit -am "add helloworld project and users"
            3git remote add origin ssh://git@hostname/helloworld.git
            4git push origin master

          10. 安裝apache2 

          1sudo apt-get install apache2

          11. 安裝gitweb

          1sudo apt-get install gitweb

          12. 配置 gitweb

          • 默認沒有 css 加載,把 gitweb 要用的靜態(tài)文件連接到 DocumentRoot 下:

            1cd /var/www/
            2sudo ln -s /usr/share/gitweb/* .
          • 修改配置:

            1sudo vi /etc/gitweb.conf

          將 $projectroot 改為git倉庫存儲目錄(例如:/home/git/repositories),保存后刷新瀏覽器。
          如果沒有找到項目,你需要將$projectroot/*.git 的屬性改為755,讓apache用戶有可讀權(quán)限??梢灾桓哪阈枰寗e人通過web訪問的那個git。 http://localhost/cgi-bin/gitweb.cgi

          • 修改/etc/gitweb.conf 內(nèi)容:

            01# path to git projects (<project>.git)
            02#$projectroot = "/var/cache/git";
            03$projectroot = "/home/git/repositories";
            04 
            05# directory to use for temp files
            06$git_temp = "/tmp";
            07 
            08# target of the home link on top of all pages
            09$home_link = $my_uri || "/";
            10 
            11# html text to include at home page
            12$home_text = "indextext.html";
            13 
            14# file with project list; by default, simply scan the projectroot dir.
            15$projects_list = $projectroot;
            16 
            17# stylesheet to use
            18@stylesheets = ("/gitweb/static/gitweb.css");
            19 
            20# javascript code for gitweb
            21$javascript = "/gitweb/static/gitweb.js";
            22 
            23# logo to use
            24$logo = "/gitweb/static/git-logo.png";
            25 
            26# the 'favicon'
            27$favicon = "/gitweb/static/git-favicon.png";
            28 
            29# git-diff-tree(1) options to use for generated patches
            30#@diff_opts = ("-M");
            31@diff_opts = ();

          13. 配置apache2

          ubuntu中默認的web目錄是/var/www,默認的cgi目錄是 /usr/lib/cgi-bin/,安裝完成gitweb后,gitweb的gitweb.cgi會自動放置到該目錄下。

          如果你的cgi路徑不是默認的/usr/lib/cgi-bin/,需要將gitweb安裝在/usr/lib/cgi-bin中的 gitweb.cgi復制到原來配置的cgi-bin路徑,并在apache的配置文件/etc/apache2/apache.conf末尾加上以下內(nèi) 容:

          01SetEnv  GITWEB_CONFIG   /etc/gitweb.conf
          02<Directory "/srv/www/cgi-bin/gitweb">          
          03     Options FollowSymlinks ExecCGI         
          04     Allow from all                         
          05     AllowOverride all                      
          06     Order allow,deny                       
          07     <Files gitweb.cgi>
          08          SetHandler cgi-script
          09     </Files>                   
          10     RewriteEngine on
          11     RewriteCond %{REQUEST_FILENAME} !-f
          12     RewriteCond %{REQUEST_FILENAME} !-d
          13     RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
          14</Directory>

          重新啟動apache:sudo /etc/init.d/apache2 restart,訪問http://localhost/cgi-bin/gitweb.cgi

          轉(zhuǎn)自:

          http://my.oschina.net/mercury5/blog/146171

          主站蜘蛛池模板: 新宁县| 新兴县| 乌审旗| 新郑市| 南开区| 邯郸县| 岑巩县| 康定县| 柳州市| 泰宁县| 清水河县| 驻马店市| 逊克县| 井研县| 含山县| 乌拉特后旗| 七台河市| 孟村| 宝山区| 大港区| 西充县| 临猗县| 新宁县| 平乡县| 海门市| 荥阳市| 台前县| 裕民县| 绍兴市| 永泰县| 通山县| 天峨县| 桑日县| 美姑县| 三亚市| 嵊泗县| 温宿县| 竹山县| 故城县| 称多县| 绍兴市|