CentOS on the build git server steps detailed

Source: Internet
Author: User
Tags mkdir socket svn ssh port using git git clone

Git is a distributed version control software that was originally created by the Linux kernel developer Linus Torvalds to better manage Linux kernel development. So far, Git has become a fairly useful version management tool. Compared to SVN, if you want to save some minor changes must be submitted to the server to save it, so that the server's version number is too much, and git to solve the problem, some small changes can only be submitted locally, only the final modification is completed before submitting the server. Thanks to this convenience, more and more community projects are now starting to use Git instead of the more traditional version management tools such as SVN.

Using CentOS to build git server is a relatively easy thing, this time toss mainly involves git, gitosis, gitweb installation configuration. Among them, gitosis and Gitweb are two more common ways, gitosis is to access and manage Git in ssh, gitweb is accessed and managed via HTTP. Use these tools to meet the basic functionality of a GIT server. In addition, the better thing is that Git's management tools do little to bring performance pressure on the server. Here's a formal start to our git installation configuration record.

First, install Git

Yum Install git
Then configure:

Useradd--home/home/git git
passwd git
After you create the user, you can switch to the following settings, such as user name and mailbox, under git User:

Su git
git config--global user.name "Somebody"
git config--global user.email "somebody@example.com"
Setting defaults will be saved in the ~/.gitconfig file.

At this point, Git's functionality is already available. To facilitate subsequent operations, you can first create an empty version library.


mkdir ~/repo
Then build the project directory


mkdir ~/repo/huhamhire-hosts
Switch to the project directory and initialize


CD ~/repo/huhamhire-hosts
Git init-bare
At this point, an initial empty project version library is configured to complete, and after installing gitosis, we can push our code base content to Couchen.

Second, install Gitosis

Before installing, you can take a look at the gitosis implementation principle:

http://geeklu.com/2012/10/gitosis/

Switch back to root permissions first.


Su Root
and install Python-setuptool first


Yum Install Python-setuptools
Then start installing gitosis, and it's worth noting that Gitosis's installer itself is managed by git and needs to be retrieved using Git. This is done in the/tmp directory for related installation operations:


Cd/tmp
git clone https://github.com/res0nat0r/gitosis.git
Next, go to the downloaded Gitosis version library for installation:


CD gitosis
Python setup.py Install
After the installation is complete, it enters the set stage of the gitosis. Because gitosis needs to be managed through SSH, an SSH key pair needs to be created and the public key is placed on the server side and the private key is placed on the client. The general process is that after the client creates the key, the public key is passed to the server for effective. However, lazy words directly on the server to operate the problem is not small.

Switch to git user and set up a folder. SSH:


Su git
Mkdir/home/git/.ssh
It must be remembered that the public key is generated on the client, uploaded to the server, or generated on the server, downloaded to the client.

Enter the ~/.ssh directory and use Ssh-keygen to generate the public key:


Cd/home/git/.ssh
SSH-KEYGEN-T RSA
Note the password for the private key cannot be forgotten. The ~/.ssh/id_rsa.pub public key file is generated by default.

Once you have the key, you can initialize the gitosis to allow Gitosis to gain administrative rights over git:


Gitosis-init After initialization, a Gitosis-admin.git project is created in/home/git/repositories that can be configured to gitosis by maintaining the project.

In addition, special permissions are required for the Gitosis-admin.git/hooks/post-update directory:


chmod u+x/home/git/repositories/gitosis-admin.git/hooks/post-update
At this point, the server-side Gitosys configuration is complete.

Third, set up and use Gitosys

After the Gitosys configuration has been completed on the server side, the following settings can be made at the client to use the GIT server.

A more formal approach is to make administrative settings through the Gitosis-admin version library, and then submit it to the server for Project permissions to take effect, and of course it can be validated using the operating system's SSH login method, but only one of the previous methods is described here.

When doing the following, you need to make sure that your public key is already in the client ~/.ssh/directory. If you're using GitHub, then you need to set up a lot of things that the public key coexists with. Ssh/config, write in this file:

Host github.com
HostName github.com
User git
Identityfile C:/users/abc/.ssh/id_rsa
Host git.oschina.net
HostName git.oschina.net
User git
Identityfile c:/users/abc/.ssh/id_rsa_a
Host Abc.ueder.info
HostName Abc.ueder.info
User git
Port 1000
Identityfile c:/users/abc/.ssh/id_rsa_new
If I have used several git services, each with its own public key, requires a profile to differentiate, and my own server SSH port is not the default port, it needs to be declared in the configuration file, or the port will be declared at each clone.

Download the Gitosis-admin version library on the client, as an example of a Linux client:

git clone Git@vps's ip/domain:/home/git/repositories/gitosis-admin.git
To set up the gitosis-admin/gitosis.conf file after getting done, take the new project above as an example and add:

[Group Huhamhire-hosts]
writable = Huhamhire-hosts
Members = Hamhire@myhost
The client's public key is then placed under the Keydir directory and subsequently committed to the server:

CP ~/.ssh/id_rsa.pub ~/gitosis-admin/keydir/hamhire@myhost.pub

CD ~/gitosis-admin
git Add./
Git commit-a-M "Add new Repo"
git push
Since the Huhamhire-hosts repository location was previously set in the/home/git/repo/directory, the push operation can be done directly.

In this example, the project can be submitted through the hamhire@myhost:/home/git/repo/huhamhire-hosts path.

At this point, the Gitosys configuration is complete.

Iv. installation of Gitweb

After the configuration completes the Git server, it is a good choice to use Gitweb to provide a simple version of the display interface if you need to make it easy to view online.

The installation of Gitweb under CentOS is as follows:

Yum Install Fcgi-devel

cd/usr/local/src/
git clone git://github.com/gnosek/fcgiwrap.git
CD Fcgiwrap
Autoreconf-i
./configure
Make
Make install
At this point, Fcgiwrap has been installed to the/usr/local/sbin/fcgiwrap

And then install spawn-fcgi.

Yum Install spawn-fcgi

After installation:

vim/etc/sysconfig/spawn-fcgi

Modify the file as:

# You must set some working options before the "spawn-fcgi" service would work.
# If SOCKET points to a file, then this file is cleaned up by the init script.
#
# spawn-fcgi (1) for all possible options.
#
# Example:
#SOCKET =/var/run/php-fcgi.sock
#OPTIONS = "-u apache-g apache-s $SOCKET-S-M 0600-c 32-f 1-p/var/run/spawn-fcgi.pid--/usr/bin/php-cgi"
Fcgi_socket=/var/run/fcgiwrap.socket
Fcgi_program=/usr/local/sbin/fcgiwrap
Fcgi_user=nginx
Fcgi_group=nginx
Fcgi_extra_options= "-M 0700"
Options= "-u $FCGI _user-g $FCGI _group-s $FCGI _socket-s $FCGI _extra_options-f 1-p/var/run/spawn-fcgi.pid--$FCGI _prog RAM "
And then set the boot up operation:


Chkconfig--levels 2345 spawn-fcgi on
/etc/init.d/spawn-fcgi start
The installation of fcgi has been completed here. If you use a nginx, you also need to configure the nginx.conf to send a. CGI request to Fcgiwrap.socket

location/cgi-bin/{
# Disable gzip (it makes scripts feel slower since they to have
# before getting gzipped)
gzip off;
# Set The root to/usr/lib (inside this location it means that we are
# giving access to the files Under/usr/lib/cgi-bin)
root/var/www/www.example.com;
# Fastcgi Socket
Fastcgi_pass Unix:/var/run/fcgiwrap.socket;
# Fastcgi parameters, include the standard ones
Include/etc/nginx/fastcgi_params;
# Adjust Non standard parameters (Script_filename)
Fastcgi_param script_filename $document _root$fastcgi_script_name;
}
The last reboot Nginx is OK.

Five, the gitweb of the interface beautification and the Chinese culture

Personally feel gitweb the default user interface is a bit shabby, really uncomfortable, you can use the style sheet for proper decoration

Related Article

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.