Linux configuration Gitolite+gitweb+nginx steps detailed

Source: Internet
Author: User
Tags chmod http authentication redmine


Gitolite is a very powerful GIT server building tool, you can easily implement user rights management functions. But Gitolite is a pure git server, unlike projects like Gitlab, which do not have other access and browsing methods themselves.

Before the server also configured Gitolite, while with Redmine to use. For me, both Gitlab and redmine are too rich. In fact, your own server upload gitolite just put some private libraries, I just need a simple intuitive web browsing function. On project collaboration, whether it is GitHub or domestic gitcafe and OSC are very good choices.

So this time pick to pick to choose the simplest gitweb to achieve. Most of the tutorials that were found are based on Apache+gitweb, and Nginx have some additional requirements to configure in conjunction with Gitweb. So write down this article for a little record.

Directory

Installation and configuration of Gitolite

Installation and configuration of Gitweb

Configuration of Nginx

1.Gitolite Installation and Configuration

① Basic Installation Configuration

The installation of Gitolite is actually very simple. The official document was written in quite detail.

First clone the code down, with the installation script installed to the/usr/local/gitolite and then do a soft connection.

Then add a user who has disabled the password:

sudo adduser \
--system \
--shell/bin/bash \
--group \
--disabled-password \
--home/home/git git

Switch to the user and Gitolite setup. Admin.pub is the administrator's public key, which is advanced to the server on the SCP.


Su-git
Gitolite Setup--pubkey admin.pub

At this time this machine already can clone gitolite-admin repo.

②gitweb Extra Configuration

Additional configuration is required to prepare for gitweb access. It mainly deals with file system permissions and Repo permissions issues.

First, modify the umask in the/home/git/.gitolite.rc and change the 0007 to 0027. Simultaneous execution:


sudo usermod-a-g git www #www是我运行服务器的用户, modified by itself
sudo chmod g+r/home/git/projects.list
sudo chmod-r g+rx/home/git/repositories

Add the Web server's execution users to the GIT group and ensure that file system permissions also work for existing files.

The other thing to note is that Gitweb reads and determines which repo can be displayed (exactly as shown on the home page, later gitweb configuration section), and in Gitolite, you need to set permissions R = Repo for a specific gitweb projects.list In order to make the repo be added to the projects.list.

2.Gitweb Installation and Configuration
Installation of ①gitweb

Gitweb can be installed directly through package management software. However, in general, the software source Gitweb will be listed as dependent Apache, if you have installed the first nginx to remember to disable the Apache service.
Take the Debian department as an example and execute:

1
sudo apt-get install Gitweb highlight
Where highlight is used to provide the ability to highlight code.

Configuration of ②gitweb

The default location for gitweb configuration files is/etc/gitweb.conf. The following is an example of a configuration file.


# Path to git projects (<project>.git)
$projectroot = "/home/git/repositories/";

# directory to use for temp files
$git _temp = "/tmp";

# target of ' home link on ' top ' all pages
# $home _link = $my _uri | | "/";

# HTML text to include at home page
# $home _text = "indextext.html";

# file with Project list; By default, simply scan the Projectroot dir.
$projects _list = "/home/git/projects.list";
$strict _export = 1;

# stylesheet to use
# @stylesheets = ("Static/gitweb.css");

# JavaScript code for Gitweb
$javascript = "Static/gitweb.js";

# logo to use
$logo = "Static/git-logo.png";

# the ' Favicon '
# $favicon = "Static/git-favicon.png";

# Git-diff-tree (1) options to use for generated patches
# @diff_opts = ("M");
@diff_opts = ();

$feature {' blame '} {' default '} = [1];
$feature {' blame '} {' override '} = 1;

$feature {' snapshot '} {' default '} = [' Zip ', ' tgz '];
$feature {' snapshot '} {' override '} = 1;

$feature {' Highlight '} {' default '} = [1];
Where $projectroot and $projects_list are well understood, specify repo directories and projects.list locations. If Projects.list is not specified, Gitweb automatically finds the legitimate git repo recursively in the directory defined by $projectroot.

$strict _export parameters only the repo displayed on the home page can be accessed. In other words, in the case of Projects.list, the repo listed in the file can be accessed. Without this, though gitolite-admin this important catalogue will not be listed in Projects.list (who would do this ...). , but can be accessed directly by modifying the URL parameters. Default this option is not open, really is very unsafe ... Flipping through the developer's opinion, it seems to be true that you should open it by default to enhance security, but consider compatibility issues that have not been modified.

$feature array has some plug-ins or attributes enabled. Blame can display code sources, snapshot provides repo package downloads, highlight provides code highlighting.

3.nginx of configuration
There are no special requirements for the installation of Nginx, the tutorial is not a lot of talk. Mainly talk about how to run up with Nginx Gitweb.

Nginx run Gitweb need spawn-fcgi and fcgiwrap support.

sudo apt-get install spawn-fcgi fcgiwrap

After installation, modify the/etc/init.d/fcgiwrap to change the Fcgi_user fcgi_group fcgi_socket_owner Fcgi_socket_group to the user running the Web server (on my server is WWW).

Then add a new server segment to the Nginx configuration file

server {
Listen 80;
server_name gitweb.example.com;
Access_log/home/wwwlogs/access.log main;

Location/{
Root/usr/share/gitweb;
Index index.cgi;
Include Fastcgi_params;
gzip off;
Fastcgi_param gitweb_config/etc/gitweb.conf;

if ($uri ~ "/index.cgi") {
Fastcgi_pass Unix:/var/run/fcgiwrap.socket;
}
}
}

This way of using the fcgiwrap is very simple and crude, as with PHP-FPM no pool. But here Fcgiwrap is only used to run Gitweb one, just make use of it.

Restart Fcgiwrap and Nginx to see the effect.

If you are a private site, consider adding robots.txt and adding a simple HTTP authentication with Nginx Auth_basic.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.