1. Preface
Git is a version control tool, similar to SVN.
This article mainly involves the GIT repository through the browser access (using the Web to view the git commit history, tag,branch and other information), that is, Gitweb.
:
Here the Gitweb running process (component), easy to organize ideas and follow-up to find the problem, the composition diagram:
To build Gitweb, you must prepare three primary environment support: Apache, CGI runtime, git
Apache provides browsers in a way that, like SVN can be accessed via a browser, is supported by Apache
CGI is used here to parse the gitweb.cgi script (just as HTML parses through the browser and becomes a Web page)
git environment support, like running Java programs, must have the same JDK environment
2. Git repository initialization
Here the warehouse functions like a database to store your code
sudo mkdir demo2cd Demo2/sudogit initinitialized empty git repositoryinch/data/git/demo1/demo2/.git/ls-Latotal0drwxr-xr-x3Root Wheel102 8 9 A: the. DRWXR-xr-x6Root Wheel204 8 9 A: - .. DRWXR-xr-xTenRoot Wheel340 8 9 A: the. Git//readme.md New FileAdd the newly created file to the Git index (. Not less, which means all files in the current directory)sudogit Add. Git status//view status
On Branch Masterinitial CommitChanges to is committed: ( use"git rm--cached <file>"To unstage) Newfile: readme.md
Submit
sudo git commit-am "init"
[Master (Root-1file2 insertions (+100644 readme.md
3. Configuring the Apache CGI module
CGI as can be referenced (http://www.cnblogs.com/web1992/p/4525286.html)
Check to see if your Apache has a CGI module installed, as follows
sudo apachectl-m | grep CGI//The presence of this cgi-module indicates that the CGI proxy_fcgi_module (shared) proxy_scgi_module (shared) cgi_module (shared) has been installed
In the Apache httpd.conf configuration file, add
Include/etc/apache2/vhost/*.conf
#这里的意思我的 The gitweb.conf file is placed under the/etc/apache2/vhost/folder,
The gitweb is accessed via Apache's virtual host (Vhost), which is configured as follows (all in English):
Localhost:vhost web$Catgitweb.conf #Alias/git/usr/local/git/share/Gitweb#alias/git/usr/local/git-share/share/Gitwebalias/git/usr/local/share/gitweb/gitweb/<Directory/usr/local/share/gitweb/gitweb/>#Options+execcgi #AddHandler CGI-script. CGI #DirectoryIndex gitweb.cgi # Let anyone see our repositories ( forNow ) Order allow,deny allowoverride None # rquiree all granted Options Indexes followsymlinks execcgi allow from all SATISF Y any # Enable CGIinchThis directory Options+execcgi # Run. cgi files using mod_cgi AddHandler CGI-script. CGI # use gitweb.cgi fordirectory listings. This takes care of # requests to/git and/git/
# Configure Index
DirectoryIndex gitweb.cgi # This tells Gitweb.cgi where toFindits configfile# By default it looksinch/etc/gitweb.conf, soifYou place # your configfileSomewhereElseYou should specify this. #SetEnv Gitweb_config/etc/gitweb.conf #SetEnv gitweb_config/usr/local/git/share/gitweb/gitweb-css.conf
# Configure Git repository location, CSS style, git install path
# gitweb-css.conf is very important SETENV Gitweb_config/usr/local/share/gitweb/gitweb/gitweb-css.conf # Enable mod_rewrite rewriteengine on # rewrite/git/repo.git URIs to be/git/gitweb.cgi/Repo.git # assumes your repository names end with'. Git'. I Don'T# knowifThat's always a safe assumption. Rewriterule^([^.] +\.git.*) $/git/gitweb.cgi/$0[L,PT]</Directory>
Note here that my gitweb related CGI scripts & static resources (CSS,IMG, etc.) are all in
/usr/local/share/gitweb/gitweb/
Below the file, as follows:
Localhost:vhost web$ls-la/usr/local/share/gitweb/gitweb/ Total504drwxr-xr-x5Web Admin the 8 9 on: +. DRWXR-xr-x3Web Admin102 8 9 on: One ..-rw-r--r--1Web Admin1303 8 9 on: +gitweb-css.conf-rwxr-xr-x1Web Admin251379 8 9 on: theGITWEB.CGIDRWXR-xr-x6Web Admin204 8 9 on: Onestaticlocalhost:vhost web$
4. Gitweb CGI script configuration & static resource configuration
Gitweb-css.conf content:
Localhost:vhost web$Cat/usr/local/share/gitweb/gitweb/gitweb-css.conf ###################################################################################### This is the directory where your git repositories live
# Git's warehouse location is very important $projectroot='/data/git/'; # This is the title of the Site$site_name="Use gitweb site for stupid stupid."; # used to generate the URI forEach Repo$my_uri="/git"; # Text and URI forThe home link$home_link_str="My Projects";
# doesn't seem to support Chinese%>_<%# $home _link_str="Use Projects, stupid , stupid, stupid."; $home _link="/git"; # These tell gitweb the URIs forThe images and CSS it needs.# depending on the version of Gitweb you had there may be# different locations. Newer versions include a/static/path# element and a JavaScript library.###### older gitweb ####################### @stylesheets= ("/git/gitweb.css"); # $logo="/git/git-logo.png"; # $favicon="/git/git-favicon.png"; # $javascript="/git/gitweb.js"The path of the CSS style is configured here, and if the configuration is incorrect, the page will be ugly ~~##### newer gitweb ####################### @stylesheets= ("/git/static/gitweb.css"); $logo="/git/static/git-logo.png"; $favicon="/git/static/git-favicon.png"; $javascript="/git/static/gitweb.js"just makes the description field wider so can read # it better$projects_list_description_width= -; # This makes repo links use the pretty URLs like/git/repo.git$feature{'PathInfo'}{'default'} = [1];
Edit gitweb.cgi in about 77 lines of the file, you can find our $GIT here to set up the GIT installation path (if the installation git path is not configured incorrectly, will report 500 internal error)
the# core Git executable to use About# This can just is"git" ifyour webserver has a sensible PATH the#our $GIT ="/usr/local/git/bin/git"; the#our $GIT ="/usr/local/bin/git"; theOur $GIT ="/usr/bin/git"; + -# absolute Fs-pathwhichWould be prepended to the project path the#our $projectroot ="/PUB/SCM"; BayiOur $projectroot ="/pub/git";
The first line can see the #!/usr/bin/perl words, using Perl written pages (good envy??). )
1 #!/usr/bin/perl 2 3 in git repositories 4 # 52005-2006, Kay sievers <[email protected]> 6 2005 , Christian Gierke 7 # 8 # This program is licensed under the GPLV2
How to query your git installation path
which git/usr/bin/git
After configuring this here, restart Apache in browser access: http://127.0.0.1/git/
Giweb Accessories: Http://pan.baidu.com/s/1c0nqjxY
End ~
Gitweb Construction Tutorial