1. gitweb安裝
注意:redhat的iso源是沒有gitweb安裝包,但是centos的源中有,在上一篇文章中給出了如何讓redhat使用centos的源,那麼,只需採用如下命令即可安裝。
- # yum install gitweb
2. gitweb配置
gitweb預設安裝到了/var/www/git下,其設定檔在/etc/gitweb.conf下,另外,httpd的設定檔/etc/httpd/conf.d/git.conf。(1)修改/etc/gitweb.conf
- $projectroot = "/var/www/git" //將projectroot修改為/var/www/git
(2)修改/etc/httpd/conf.d/git.conf
- Alias /git /var/www/git
- <Directory /var/www/git>
- Allow from all
- AllowOverride all
- Order allow,deny
- Options +ExecCGI
- AddHandler cgi-script .cgi
- DirectoryIndex gitweb.cgi
- SetEnv GITWEB_CONFIG /etc/gitweb.conf
- Dav On
- RewriteEngine Off
- </Directory>
(3)重啟httpd
- /etc/init.d/httpd restart
(4)將gitosis倉庫串連到/var/www/git下,完成web顯示
- ln -s /home/git/repositories/test_repo.git /var/www/git/
(5)通過瀏覽器瀏覽
http://xxxx/git/
注意: 如果git clone http://xxx/git/test_repo.git時出現git update-server-info錯誤,則在test_repos.git目錄下執行 git update-server-info 命令即可(gitosis伺服器的相應倉庫下)。
3. 建立新的git repository在git server的/home/git/repository目錄下,執行如下命令:
- mkdir test.git
- cd test.git
- git init --bare
- //可以在這裡添加源檔案,也可以在client端clone之後添加