CentOS安装Git服务器 Centos 7.0 + Git 2.2.0 + gitosis (实测 笔记)

环境:

系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡)

系统版本:CentOS-7.0-1406-x86_64-DVD.iso

服务器IP:192.168.1.31 域名:www.domain.com SSH端口:8200(默认为22)

安装步骤:

1.显示服务器版本
[[email protected] ~]# cat /etc/redhat-release
#CentOS Linux release 7.0.1406 (Core)

[[email protected] ~]# uname -a
#Linux tCentos7 3.10.0-123.9.3.el7.x86_64 #1 SMP Thu Nov 6 15:06:03 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[[email protected] ~]# ipconfig
#服务器IP192.168.1.31

2.安装git

#2.1 下载git-2.2.0.tar.gz 到 /usr/local/src

[[email protected] ~]# cd /usr/local/src

[[email protected] ~]# wget https://www.kernel.org/pub/software/scm/git/git-2.2.0.tar.gz

#2.2 安装依赖的库

[[email protected] ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel

#2.3 删除原本的安装的git

[[email protected] ~]# yum remove git -y

#2.4 编译安装
[[email protected] ~]# cd /usr/local/src

[[email protected] ~]# tar -zvxf git-2.2.0.tar.gz

[[email protected] ~]# cd git-2.2.0

[[email protected] ~]# make prefix=/usr/local/git all

[[email protected] ~]# make prefix=/usr/local/git install

#2.5 增加软连接

[[email protected] ~]# ln -s /usr/local/git/bin/* /usr/bin/

[[email protected] ~]# git --version

#如何能显示版本号,即表示成功

3.安装gitosis
[[email protected] ~]# yum install python python-setuptools

[[email protected] ~]# cd /usr/local/src

[[email protected] ~]# git clone git://github.com/res0nat0r/gitosis.git

[[email protected] ~]# cd gitosis

[[email protected] ~]# python setup.py install

#显示Finished processing dependencies for gitosis==0.2即表示成功

*******************************************************

4.修改客户端git连接端口(如果GIT服务器为默认SSH端口为22,则不需要以下步骤)

#修改开发机客户端配置文件(可以省略每次输入端口)

[[email protected] ~]# mkdir  ~/.ssh

[[email protected] ~]# vim ~/.ssh/config

#打开后,编辑文件,添加以下代码
host www.domain.com
hostname www.domain.com
port 8200

#修改后,开发机客户端即可用以下方式进行连接访问
#git clone ssh://[email protected]/gitosis-admin.git

#否则需要需要加上端口进行访问

#git clone ssh://[email protected]:8200/gitosis-admin.git
*******************************************************

5.在开发机客户端上,生成密钥并上传到服务器上

ssh-keygen -t rsa
#一路回车,不需要设置密码

#从开发机客户端,上传刚生成的公钥到服务器(如果修改端口,按4进行配置指定端口)
scp ~/.ssh/id_rsa.pub [email protected]:/tmp/

#显示已经上传的密钥

[[email protected] ~]# ls /tmp/id_rsa.pub

6.服务器上生成git用户,使用git用户并初始化gitosis

#6.1 增加git用户

[[email protected] ~]# adduser -m git

#6.2切换用户
[[email protected] ~]# su - git

#6.3 服务器的公钥(刚才开发机客户端上传),导入后此开发机客户端即可以管理git服务器。

[[email protected] ~]# 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/

#6.4 删除密钥
[[email protected] ~]# su - root
[[email protected] ~]# rm -rf /tmp/id_rsa.pub

6.在开发机客户端,复制git管理项目(git服务器管理,也是一个git仓库)
mkdir -p /repo
cd /repo
git clone [email protected]:gitosis-admin.git

7.在开发机客户端,增加及设置管理项目
cd /repo/gitosis-admin

#查看已经上传密钥
ls keydir
cat keydir/vicowong\@VICO.pub #[email protected]为已经上传的开发机生成的公密

#显示密钥最后的符串为密钥用户名 这里为[email protected]

vim gitosis.conf

#在文件尾增加以下内容
[group test-git] # 组名称
writable = test-git # 项目名称
members = [email protected] #密钥用户名

#提交修改
git add .
git commit -a -m "add test-git repo"
git push

9.在开发机客户端,初始,增加及使用项目test-git
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 [email protected]:test-git.git
git push origin master

时间: 2024-08-28 09:02:56

CentOS安装Git服务器 Centos 7.0 + Git 2.2.0 + gitosis (实测 笔记)的相关文章

centos安装php服务器

easypanel 是一款免费的功能强大集开通虚拟主机,ftp空间,数据库等功能为一体的主机控制面板 , 具备跨平台(windows,linux),安全稳定.操作简便等特点.支持php(windows版本还支持asp,asp.net),支持磁盘配额,在线文件管理,在线web软件安装. 2.linux下安装及升级(集成了kangle web 服务器和mysql,仅支持centos 5和centos 6)执行下面的命令即可,安装程序将自动安装或者升级. yum -y install wget;wge

CentOS安装Git服务器 Centos 6.5 + Git 1.7.1.0 + gitosis

1.安装扩展 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel 2.下载git wget http://codemonkey.org.uk/projects/git-snapshots/git/git-2014-08-24.tar.xz 3.解压安装 xz -d git-2014-08-24.tar.xz tar xvf git-2014-08-24.tar cd git-20

CentOS 安装DHCP服务器

一.安装环境: CentOS 7  Linux version 3.10.0-229.el7.x86_64 二.安装及配置步骤: 2.1 背景网络知识 网络拓扑如下 两台服务器的IP为172.18.0.61,172.18.0.62: 用户网段为172.18.6.0/24,172.18.7.0/24: 68:F7:28:37:8E:3B 设固定IP 172.18.6.20: 服务器172.18.0.61分配IP 从30-131,172.18.0.62分配IP从131-230: 两台服务器不做主从,

git知识总结-4.git服务器搭建及迁移git仓库

1. 前言 因为手里有一份代码之前是直接从其它git服务器上克隆下来的,现在想自己搭建一个git服务器把这份代码管起来. 2. 搭建git服务器 1.安装git: $ sudo apt-get install git 2. 创建一个git用户,用来运行git服务: $ sudo adduser book 3. 创建证书登录 收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/book/.ssh/authorized_keys文件里,一行一个. 此处可

基于CentOS安装FTP服务器

操作系统环境: CentOS Linux release 7.4.1708 (Core) 使用yum安装ftp服务: yum install -y vsftpd 添加系统用户作为登录ftp服务器并修改ftp配置文件: [[email protected] ~]# useradd ftp1 -s /sbin/nologin -d /ftp_data && echo "123456"|passwd ftp1 --stdin #添加用户并设置访问的ftp目录[[email p

centos 安装ftp服务器

CentOS下搭建FTP服务器简单记录. 1.安装vsftpd yum install vsftpd 2.编辑iptablesvi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 service iptables restart 3.配置vsftpdvi /etc/vsftpd/vsftpd.conf  anonymous_enable=NO  //设定不允许匿名用户访问. 4.添加ft

centos安装PHP服务器步骤

方法一.使用网友开发的EZHTTP程序包一键安装. 可以参考地址http://www.centos.bz/2013/08/ezhttp-tutorial/ 方法二.手工安装步骤如下: 1. 安装apache: yum install httpd httpd-devel 启动apache: /etc/init.d/httpd start 此时输入服务器的IP地址,应该看到apache的服务页面,端口不用输,apache默认就是使用80端口 2. 安装mysql: yum install mysql

centos安装svn服务器

转自:http://www.blogjava.net/nkjava/archive/2011/08/29/357502.html 搭建SVN服务,有效的管理代码,以下三步可以快速搞定.1.安装 #yum install subversion 判断是否安装成功#subversion -v svnserve, version 1.6.11 (r934486)出现上面的提示,说明安装成功. 如果提示如下:-bash: subversion: command not found   经过查找发现:  [

centos安装maven服务器

http://code.skyheng.com/2016/04/17/nexus-install-and-settings/ 安装文件发布到百度云去:nexus-2.12.0-01-bundle.tar.gz 选择使用网盘下载 nexus-2.12.0-01-bundle.tar.gz 版本:链接:http://pan.baidu.com/s/1hrKNaz6 密码:nerc