Home> php教程> PHP开发> body text

Detailed explanation of server setup in Git tutorial

黄舟
Release: 2016-12-16 15:11:41
Original
1044 people have browsed it

Git server setup

In the previous chapter, our remote warehouse used Github. Github Public projects are free, but if you don't want others to see your project you will need to pay.
At this time we need to build a Git server ourselves as a private warehouse.
Next we will use Take Centos as an example to build a Git server.

1. Install Git

$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum install git

Next we create a git user group and user to run the git service:

$ groupadd git
$ adduser git -g git

2. Create certificate login

Collect the public keys of all users who need to log in. The public keys are located in the id_rsa.pub file. Import our public keys into the /home/git/.ssh/authorized_keys file. A row.

Create it if there is no such file:

$ cd /home/git/ $ mkdir .ssh $ chmod 700 .ssh $ touch .ssh/authorized_keys $ chmod 600 .ssh/authorized_keys
Copy after login

3. Initialize the Git repository

First we select a directory as the Git repository, assuming it is /home/gitrepo/w3cschoolcc.git, in /home Enter the command in the /gitrepo directory:

$ cd /home $ mkdir gitrepo $ chown git:git gitrepo/ $ cd gitrepo $ git init --bare w3cschoolcc.git Initialized empty Git repository in /home/gitrepo/w3cschoolcc.git/
Copy after login

The above command Git creates an empty warehouse. Git warehouses on the server usually end with .git. Then, change the user of the warehouse to git:

$ chown -R git:git w3cschoolcc.git

4. Clone the warehouse

$ git clone git@192.168.45.4:/home/gitrepo/w3cschoolcc.git Cloning into 'w3cschoolcc'... warning: You appear to have cloned an empty repository. Checking connectivity... done.
Copy after login

192.168.45.4 is the server IP where Git is located. You need to change it to your own Git service IP.

In this way, our Git server installation is complete, and then we can disable git User login through shell can be completed by editing the /etc/passwd file. Find a line similar to the following:

git:x:503:503::/home/git:/bin/bash

Change to:

git:x:503:503::/home/git: /sbin/nologin

The above is the detailed explanation of the server setup of the Git tutorial. For more related articles, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!