切换导航
首页
技术问答
编程语言
前端开发
移动开发
开发工具
程序设计
行业应用
CMS系统
服务器
频道导航
▸ PHP
▸ Java
▸ Java SE
▸ Python
▸ C#
▸ C&C++
▸ Ruby
▸ VB
▸ asp.Net
▸ Go
▸ Perl
▸ netty
▸ Django
▸ Delphi
▸ Jsp
▸ .NET Core
▸ Spring
▸ Flask
▸ Springboot
▸ SpringMVC
▸ Lua
▸ Laravel
▸ Mybatis
▸ Asp
▸ Groovy
▸ ThinkPHP
▸ Yii
▸ swoole
▸ HTML
▸ HTML5
▸ JavaScript
▸ CSS
▸ jQuery
▸ Bootstrap
▸ Angularjs
▸ TypeScript
▸ Vue
▸ Dojo
▸ Json
▸ Electron
▸ Node.js
▸ extjs
▸ Express
▸ XML
▸ ES6
▸ Ajax
▸ Flash
▸ Unity
▸ React
▸ Flex
▸ Ant Design
▸ Web前端
▸ 微信小程序
▸ 微信公众号
▸ iOS
▸ Android
▸ Swift
▸ Hybrid
▸ Cocos2d-x
▸ Flutter
▸ Xcode
▸ Silverlight
▸ cocoa
▸ Cordova
前端之家
CentOS
基于CentOS 6.8的Git服务器的搭建
基于CentOS 6.8的Git服务器的搭建
2020-06-21
CentOS
前端之家
前端之家
收集整理的这篇文章主要介绍了
基于CentOS 6.8的Git服务器的搭建
,
前端之家
小编觉得挺不错的,现在分享给大家,也给大家做个参考。
基于CentOS 6.8的Git服务器的搭建 VM虚拟机或是直接安装 CentOS6.8,选择开发者选项,尽量全部选择安装的软件包。 一:SSH服务器sshd已经安装了。 二:Git客户端已经安装了。 三:Git管理需要重新安装与启动:gitosis 四:新建
用户
并初始化Git版本仓库。 需要的工具:ssh python python-tools git gitosis 客户端: (1)ssh-keygen.exe -t rsa (2)scp.exe /c/Users/fsmd/.ssh/id_rsa.pub root@10.103.3.167:~/ 问题与思考: (1)多少Git
用户
,就需要建立多少个Linux
用户
吗? (2)
用户
自己建立版本仓库。
上传
KEY? (3)多
用户
的使用问题:需要组group管理? 目前CentOS6.8上已经成功搭建了个人版本的Git服务器,目前流程基本上清楚了,但是,还没有熟悉。 最好继续测试与验证。掌握最直接的
方法
。最好备份,可以不断的尝试。 一:安装CentOS6.8。 这里使用VM安装。 CentOS-6.8-x86_64-bin-DVD1.iso 120G硬盘。 开发者模式安装,这里选择默认的软件包,ssh git python 等已经安装。 如果没有默认安装,需要自己重新安装即可。 二:安装与配置gitosis 使用
管理员
账号安装,这里还需要python与
支持
python tools 安装。 三:新建git的
用户
与配置密码。 这里是否需要sudo的加入呢?还是普通
用户
即可。 四:
用户
生成
自己的ssh-keygen,用于管理自己的git仓库。 目录的访问权限的问题:sudo还是直接
管理员
创建。chmod一下? 五:测试与验证。 git clone git add . git commmit -a git push origin master 目前已经安装完成了,安装一下VM tools,这是方便
文件
与
文字
的复制与粘贴。 (1)查看一下VM虚拟机CentOS 6.8 服务器的IP地址。 [fsmd@localhost Desktop]$ ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:72:56:3A inet addr:10.103.3.113 Bcast:10.103.3.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe72:563a/64 Scope link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:247 errors:0 dropped:0 overruns:0 frame:0 TX packets:33 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:26785 (26.1 KiB) TX bytes:3766 (3.6 KiB) (2)查看一下服务器上的Git是否安装。 [fsmd@localhost Desktop]$ git --version git version 1.7.1 (3)查看一下服务器上的python是否安装 [fsmd@localhost Desktop]$ python Python 2.6.6 (r266:84292,Jul 23 2015,15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help","copyright","credits" or "license" for more information. >>> exit() [fsmd@localhost Desktop]$ (4)查看一下服务器的sshd服务是否安装与启动。 [fsmd@localhost Desktop]$ /etc/init.d/sshd status /etc/init.d/sshd: line 33: /etc/sysconfig/sshd: Permission denied openssh-daemon (pid 2668) is running... 以上是基于CenOS6.8搭建Git服务器需要的。另外,还需要下载Gitosis用于管理Git。 (5)安装gitosis。这里使用
管理员
root账号直接安装。 [root@localhost Git]# unzip gitosis-master.zip [root@localhost Git]# ls gitosis-master gitosis-master.zip [root@localhost Git]# cd gitosis-master [root@localhost gitosis-master]# ls COPYING example.conf lighttpd-gitweb.conf README.rst debian gitosis MANIFEST.in setup.py etc-event.d-local-git-daemon gitweb.conf mirror.conf TODO.rst [root@localhost gitosis-master]# python setup.py install (6)新建git
用户
: [root@localhost Desktop]# useradd -r -s /bin/sh -c 'git version control' -d /home/git git [root@localhost Desktop]# mkdir -p /home/git [root@localhost Desktop]# chown git:git /home/git [root@localhost Desktop]# ll /home/ total 24 drwx------. 27 fsmd fsmd 4096 Jan 16 22:14 fsmd drwxr-xr-x. 2 git git 4096 Jan 16 22:34 git drwx------. 2 root root 16384 Jan 16 21:25 lost+found 设置一下git
用户
的密码: [root@localhost Desktop]# passwd git Changing password for user git. New password: Retype new password: passwd: all authentication tokens updated successfully. (7)客户端:这里是win7 64bit ,安装git。
生成
密钥并
上传
到服务器: $ ssh-keygen.exe -t rsa $ scp.exe /c/Users/fsmd/.ssh/id_rsa.pub git@10.103.3.113:~/ The authenticity of host '10.103.3.113 (10.103.3.113)' can't be established. RSA key fingerprint is SHA256:Sz6gE9OZjW2Eshtvfn2nZRzqBHElb6g5Q5lXh7Z1GLo. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.103.3.113' (RSA) to the list of known hosts. git@10.103.3.113's password: id_rsa.pub 100% 398 8.4KB/s 00:00 (8)服务端
生成
管理库(这里用git
用户
操作,而不是
管理员
) [root@localhost repositories]# chmod u+w /etc/sudoers [root@localhost repositories]# vi /etc/sudoers [root@localhost repositories]# chmod u-w /etc/sudoers [root@localhost repositories]# 这里使用git
用户
登录
,然后
生成
仓库试一下
效果
!!! [root@localhost Desktop]# sudo -H -u git gitosis-init < /home/git/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/ [root@localhost Desktop]# chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update (9)客户端测试与验证: $ git clone git@10.103.3.113:/home/git/repositories/gitosis-admin.git 注意:这里需要IP与完整的路径!!! 如果成功了,可以新建Git版本仓库了!! (10)
修改
gitosis-admin.git里的
配置文件
,把新的版本仓库加入: $ cd gitosis-admin/ $ vi gitosis.conf 问题与
解决
思路: (1)目前单机版的Git服务器已经成功了。 服务器使用命令:
用户
登录
(这里的
用户
是git
用户
)。 mkdir hello.git cd hello.git git init --bare(这里是两个--) (2)客户端先
修改
gitosis.conf(是否需要
修改
,目前是
添加
了成功)。然后 git clone touch hello(新建一个空
文件
用于测试提交) git add . git commit -a git remote add git@10.103.3.113:/home/git/repositories/hello.git(目前是完整的路径) git push origin master (3)$ git clone git@10.103.3.113:/home/git/repositories/servo.git 用的是全路径,如果不是,可能出错!!目前
添加
其他的正常。但是一个却是
错误
,看看到底为何呢? (4)继续
添加
hello4。看一下操作的流程,熟悉与熟练,是不同的。 [服务器用git
用户
登录
,建立版本仓库] sh-4.1$ mkdir hello4.git sh-4.1$ cd hello4.git/ sh-4.1$ ls sh-4.1$ git init --bare Initialized empty Git repository in /home/git/repositories/hello4.git/ sh-4.1$ ls branches config description HEAD hooks info objects refs [客户端直接clone] 配置一下版本仓库与
用户
。 [group hello4] members = zhangsz@A1102127 writable = hello4 $ git clone git@10.103.3.113:/home/git/repositories/hello4.git Cloning into 'hello4'... git@10.103.3.113's password: warning: You appear to have cloned an empty repository. $ touch hello4 $ git add . $ git commit -a $ git push origin master git@10.103.3.113's password: Counting objects: 3,done. Writing objects: 100% (3/3),191 bytes | 0 bytes/s,done. Total 3 (delta 0),reused 0 (delta 0) To 10.103.3.113:/home/git/repositories/hello4.git * [new branch] master -> master 操作成功,原来不难,单机版本已经测试正常,只是,每次提交,需要密码!! 新建servo.git的操作流程: (1)服务器端的操作(这里需要使用git
用户
身份创建git版本仓库) [root@localhost repositories]# su git sh-4.1$ mkdir servo.git sh-4.1$ cd servo.git/ sh-4.1$ git init --bare Initialized empty Git repository in /home/git/repositories/servo.git/ sh-4.1$ ls branches config description HEAD hooks info objects refs (2)客户端的操作一: gitosis-admin/gitosis.conf 的配置:
添加
如下的配置即可。 [group servo] members = zhangsz@A1102127 writable = servo (3)客户端的操作二: $ git clone git@10.103.3.113:/home/git/repositories/servo.git Cloning into 'servo'... git@10.103.3.113's password: warning: You appear to have cloned an empty repository. $ ls git-test/ gitosis-admin/ hello/ hello2/ hello4/ servo/ $ cd servo/ $ ls $ touch aa $ git add . $ git commit -a [master (root-commit) 64b2691] aa 1 file changed,0 insertions(+),0 deletions(-) create mode 100644 aa $ git push origin master git@10.103.3.113's password: Counting objects: 3,184 bytes | 0 bytes/s,reused 0 (delta 0) To 10.103.3.113:/home/git/repositories/servo.git * [new branch] master -> master 测试练习:新建s.git (1)服务器端的操作: [root@localhost repositories]# su git sh-4.1$ ls gitosis-admin.git git-test.git hello2.git hello4.git hello.git servo.git sh-4.1$ mkdir s.git sh-4.1$ cd s.git/ sh-4.1$ git init --bare Initialized empty Git repository in /home/git/repositories/s.git/ sh-4.1$ (2)客户端
添加
配置: [group s] members = zhangsz@A1102127 writable = s (3)客户端操作过程: $ git clone git@10.103.3.113:/home/git/repositories/s.git Cloning into 's'... git@10.103.3.113's password: warning: You appear to have cloned an empty repository. $ cd s/ $ ls $ touch aa $ git add . $ git commit -a [master (root-commit) 7412167] aaas5 1 file changed,0 deletions(-) create mode 100644 s5 $ git push origin master git@10.103.3.113's password: Counting objects: 3,187 bytes | 0 bytes/s,reused 0 (delta 0) To 10.103.3.113:/home/git/repositories/s.git * [new branch] master -> master 总结: (1)正确的操作流程,才能提高效率。 Git
添加
其他
用户
(可以提交的
用户
) (2)
用户
通过ssh-keygen -t rsa
生成
KEY。如xxx.pub 然后发给
管理员
。
管理员
添加
到gitosis-admin/keydir/目录下。 #git add keydir/xxx.pub #git add . #git commit -a #git push origin master(服务器通过git init --bare初始化后,就有了) (3) git clone时,需要全路径,如IP:/home/git/repositories/servo.git
上一篇:centos7.2下安装mysql5.7,使用rpm
下一篇:纯净centOs 安装sentry
猜你在找的CentOS相关文章
Centos7离线安装gcc4.8
有时候CentOS工作在无互联网的环境下,需要在离线环境下安装一些组件,这次实现的是模拟在...
作者:踏平扶桑 时间:2024-09-29
CentOS7离线安装devtoolset-9并编译redis6.0.5
首先参照https://www.cnblogs.com/wdw984/p/13330074.html,来进行如何安装Centos和离线下...
作者:踏平扶桑 时间:2024-09-29
使用Nginx在80端口上代理多个.NET CORE网站
有两个.NET CORE3.1网站部署在CentOS7上(内网IP是192.168.2.32),现在想实现访问http://...
作者:踏平扶桑 时间:2024-09-29
CentOS7中配置vsftpd
1、yum -y install vsftpd 安装vsftpd 2、配置vsftpd的配置文件(/etc/vsftpd/vsftpd.conf...
作者:踏平扶桑 时间:2024-09-29
CentOS7离线安装Mysql8.0
首先去mysql官网下载mysql的离线rpm安装包(https://downloads.mysql.com/archives/commun...
作者:踏平扶桑 时间:2024-09-29
CentOS中增加网络连接数的方法
CentOS默认对外访问,发起的TCP链接总数小于28232个。 可以通过以下命令的结果计算出来 $ ...
作者:踏平扶桑 时间:2024-09-29
VMware安装Centos7虚拟机
首先安装虚拟机很简单,所以呢,具体的安装过程就引用别人的博客,这篇文字很详细,引用之...
作者:前端之家 时间:2021-02-27
[Linux] 解决CentOS下Requires: libjson-c.so错误
当安装某些rpm包的时候 , 会爆出这个错误 Requires: libjson-c.so json-c是c语言下的json库...
作者:前端之家 时间:2021-02-06
阿里云centos7安装mysql8数据库
linux系统安装mysql8
作者:前端之家 时间:2021-01-10
centos安装mysql
一、安装 二、修改密码 三、修改远程连接权限(为了使用navicat)
作者:前端之家 时间:2020-12-03
编程分类
Linux
Windows
CentOS
Ubuntu
Nginx
WebService
Scala
Memcache
Apache
Redis
Docker
Bash
Azure
Tomcat
LNMP
Shell
数据结构
服务器运维
网络安全
最新文章
• Centos7离线安装gcc4.8
• CentOS7离线安装devtoolse
• 使用Nginx在80端口上代理多
• CentOS7中配置vsftpd
• CentOS7离线安装Mysql8.0
• CentOS7下安装RabbitMQ
• CentOS中增加网络连接数的
• VMware安装Centos7虚拟机
• [Linux] 解决CentOS下Requ
• 阿里云centos7安装mysql8数
热门标签
更多 ►
xebug
nodemon
docker-copy
dcos
elasticsearc
windows-cont
docker-windo
docker-aws
amazon-cloud
envoyproxy
hashicorp-va
swisscomdev
kafka-python
zscaler
photon-os
docker-swarm
kamon
google-cloud
concourse
wso2-am
persistent-v
api-manager
process-mana
manjaro
jenkins-work
hypriot
remoteapi
keystonejs
bitcoind
bitcoin-test