msysgit+apache安装说明 - gitweb服务器部分
安装好git服务器后,虽然你可通过git clone http://...命令来操作,但还不能用浏览器来查看库的信息,这就需要安装gitweb服务器。
安装gitweb服务器需要修改两个文件,一个仍然是apache的httpd.conf,另一个是msysgit的gitweb.cgi。
一、修改apache的conf\httpd.conf配置文件
对apache服务器的配置有两种方式,一种是直接在httpd.conf里写,另一种是通过Include间接写。这里我们选用Include方式。
1、修改httpd.conf文件
在httpd.conf文件的最后加上下面一行:
Include "C:/Program Files/Git/httpd-git.conf"
这表示我们将在httpd-git.conf里写关于gitweb的配置信息。
2、创建httpd-git.conf文件
我们首先在C:\Program Files\Git\目录下创建一个名为httpd-git.conf文件,然后输入下面的内容:
# Config to make the gitweb CGI available through Apache. Alias /gitweb "C:/Program Files/Git/share/gitweb" <Directory "C:/Program Files/Git/share/gitweb"> AddHandler cgi-script .cgi <Files ~ "\.cgi$"> Options +ExecCGI </Files> AllowOverride None Order allow,deny Allow from all DirectoryIndex gitweb.cgi </Directory> # Config to make the Git html docu available through Apache. Alias /gitdocs "C:/Program Files/Git/doc/git/html" <Directory "C:/Program Files/Git/doc/git/html"> Options Includes Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory>
保存后重新启动Apache服务器,并检查是否成功启动。如果不能成功启动,请检查上面的目录是否与你的机器一致,并查看Apache的日志以获得更多的排错信息。
二、修改gitweb.cgi
msysgit自带的gitweb.cgi需要修改三处:
1、把第一行修改为:
#!C:/Program Files/Git/bin/perl
2、把第70行修改为:
our $GIT = "C:/Program Files/Git/bin/git";
3、把第74行修改为:
our $projectroot = "/e/git-parent/";
注意,这里要用msysgit的语法来写,盘符后没有冒号。
同样请检查目录是否正确。
三、启动apache
再次重新启动apache服务器,成功后请在浏览器上输入:
同样,如果你在httpd.conf里改变了默认端口号,请在上面localhost后加上端口号。