CentOS Install git server CentOS + git 1.8.5 + gitosis (notes)

Source: Internet
Author: User
Tags mkdir ssh port git clone

These two days in toss build group git server environment, just start originally want to try to use Gitlab, but install up for my Linux rookie is a bit difficult, toss for a long time Gitlab did not fix decisively gave up.

Then find some articles online to follow, may be due to the version of the server, the version of the software and other reasons, in short, I did not find an article can be described above the complete success of the installation, coupled with their own not how to contact git, so during a lot of effort.

I have an article mainly, according to its version of the installation down, there are problems asked Google uncle, find a solution to go back to the installation process to continue, finally succeeded.

Because of their lack of understanding of git, when creating a common project for other users around a large circle, almost a night to understand,?? ~~

Anyway, emperor not negative, finally or basically finished. Let's have a test with the little friends tomorrow ~ Good night~~

The installation notes are as follows:

1, install Git

The code is as follows Copy Code
Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel

2, download git source code (http://code.google.com/p/git-core)

The code is as follows Copy Code
Cd/usr/local/src
wget https://git-core.googlecode.com/files/git-1.8.5.tar.gz
TAR-ZVXF git-1.8.5
CD git-1.8.5
Make Prefix=/usr/local/git All
Make Prefix=/usr/local/git Install

———————————————————
If you are prompted for errors at compile time:
LINK Git-credential-store
LIBGIT.A (UTF8.O): in function ' Reencode_string_iconv ':
/opt/git-master/utf8.c:530:undefined reference to ' Libiconv '
LIBGIT.A (UTF8.O): in function ' Reencode_string_len ':
/opt/git-master/utf8.c:569:undefined reference to ' Libiconv_open '
/opt/git-master/utf8.c:588:undefined reference to ' Libiconv_close '
/opt/git-master/utf8.c:582:undefined reference to ' Libiconv_open '
COLLECT2:LD return 1
Make: * * * * [Git-credential-store] Error 1

Solution:

The code is as follows Copy Code
cd/usr/local/src/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
TAR-ZXVF libiconv-1.14.tar.gz
CD libiconv-1.14
./configure–prefix=/usr/local/libiconv && make && sudo make install

Then go back to Git and continue compiling:

The code is as follows Copy Code
cd/usr/local/src/git-1.8.5
Make Configure
./configure–-prefix=/usr/local–with-iconv=/usr/local/libiconv
Make
Make install

At this point, git should compile the installation successfully, you can test the following:

The code is as follows Copy Code
Cd/usr/local/bin
./git–version
git version 1.8.5

You may find out why it is not valid to enter git directly at the command line, and here you need to do some setup, edit/etc/profile, and add/usr/local/bin to the system path:

The code is as follows Copy Code
Export path= $PATH:/usr/local/bin

Save exit, and then refresh the system path:

The code is as follows Copy Code
Source/etc/profile

Enter git–-version directly in the terminal
If you can display the version correctly, git-version 1.8.5, you are done.
———————————————————

3. Installation Gitosis

The code is as follows Copy Code

Yum Install Python Python-setuptools

Cd/usr/local/src
git clone git://github.com/res0nat0r/gitosis.git
CD gitosis
Python setup.py Install

———————————————————
if the installation times are wrong:
Traceback (most recent call last):
File "setup.py", line 2, in <module>
From Setuptools import Setup, find_packages

Importerror:no module named Setuptools

Workaround:

The code is as follows Copy Code
Cd/usr/local/src
wget http://python-distribute.org/distribute_setup.py
Python distribute_setup.py

And then run it again.

The code is as follows Copy Code
Python setup.py Install

If the finished processing dependencies for gitosis==0.2 indicates that the installation was successful
———————————————————

4, generate the key on the development machine and upload to the server

The code is as follows Copy Code
ssh-keygen-t RSA #一路回车, no need to set password
SCP ~/.ssh/id_rsa.pub root@192.168.103.10:/tmp #上传公钥到服务器 (default SSH port 22)
Or
Scp-p 3600 ~/.ssh/id_rsa.pub root@192.168.103.10:/tmp

5, build git user on the server, use git user and initialize Gitosis

The code is as follows Copy Code

Adduser-m git
Su–git
Gitosis-init </tmp/id_rsa.pub
#显示以下信息即表示成功
#Initialized Empty Git repository in/home/git/repositories/gitosis-admin.git/
#Reinitialized existing Git repository in/home/git/repositories/gitosis-admin.git/

#删除密钥
Su–root
Rm-rf/tmp/id_rsa.pub

6. Export management on the development machine

The code is as follows Copy Code
Mkdir-p/repo
Cd/repo
git clone git@xxx:gitosis-admin.git
or Git clone ssh://git@xxx:3600/gitosis-admin.git

7, add and set up management project

The code is as follows Copy Code

Cd/repo/gitosis-admin
Vim gitosis.conf
#在文件尾增加以下内容
[Group Test] # groups Name
writable = test # project Name
Members = Jankerli #密钥用户名

#提交修改
git Add.
Git commit-a-M "Add test Repo"
git push

8, initial, increase and use of project Test-git

The code is as follows Copy Code
Cd/repo
mkdir Test-git
CD Test-git
Git inti
Touch Readme
git Add.
Git commit-a-M "Init Test-git"
Git remote add Origin git@xxx:test.git
Git push Origin Master

9. New users in test project
① generates the private key public key in the new user's native input ssh-keygen-t RSA;
② the generated public key id_rsa.pub upload or copy to Gitosis-admin/keydir folder, and name, such as: jankerli.pub;
③vim gitosis.conf

The code is as follows Copy Code
#在文件尾增加以下内容
[Group Test]
writable = Test
Members = Jankerli (add the name of the new user here, the name must be the same as the jankerli.pub above, remove. pub)
④ #提交修改
git Add.
Git commit-a-M "Add test Repo"
git push

⑤ new users will be able to clone code through git clone git@xxx:test.git to the local machine.

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.