没有合适的资源?快使用搜索试试~ 我知道了~
首页搭建自己的git gitweb gerrit服务器
资源详情
资源评论
资源推荐
搭建自己的 git gitweb gerrit 服务器
软硬件环境
物理机:Windows10 64 位
VMware 版本:VMware Workstation 12
Ubuntu 版本:ubuntu-14.04-server-amd64.iso
安装 Ubuntu
VMware 下 Ubuntu Server 14.04 安装教程,参考:
https://www.jianshu.com/p/0f0ed7d8e06e
教程里已经教我们安装了 ssh 服务,与该教程不一样的点:
1. 我分配给虚拟机硬盘共 100G
2. 创建的用户名是我这里是叫 flinger
3. 分区的设置我选择了 Manuel 手动设置,参考:
https://blog.csdn.net/chang_ge/article/details/52653033
我的分区情况如下:
1GB for /boot partition ext4
4GB for swap partition swap
75GB for / partition ext4
The rest for /home partition ext4
安装完成后,用 flinger 账号登录,顺便给 root 用户设置下密码:
sudo passwd
设置 root 用户的密码即可
设置固定 IP
作为 server 一般是要用静态 IP 的,把 DNS 地址也配置下,方法如下:
sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.110
netmask 255.255.240.0
gateway 192.168.2.1
dns-nameservers 8.8.8.8 114.114.114.114 223.5.5.5
dns-search foo.org bar.com
保存退出,重启网卡(需根据你的实际情况配置)
sudo ifdown eth0
sudo ifup eth0
或者重启系统
sudo reboot
可以看到我这里 IP 固定设置为 192.168.1.110
安装版本控制系统——git
安装 git
sudo apt-get install git
git 的基本操作,请参考:
https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
添加一个用户名为 gerrit 的用户,专门用来管理 git 仓库
sudo adduser gerrit
并将 gerrit 加入 sudo 权限,仿照 root 添加一行,用 wq!保存退出
sudo vi /etc/sudoers
gerrit ALL=(ALL:ALL) ALL
在 flinger 家目录生成 ssh 公钥和私钥,一路敲回车默认即可
cd ~flinger
ssh-keygen -t rsa -C "xxxxxx@yyyyyyglobal.com"
注意,这个邮箱是要能用的邮箱,如 qq 邮箱、163 邮箱等
把 flinger 用户的 ssh 公钥复制到 git 用户的 authorized_keys 文件
sudo cat /home/flinger/.ssh/id_rsa.pub | ssh gerrit@ubuntu "mkdir -p ~/.ssh && cat >>
~/.ssh/authorized_keys"
初始化一个 git 仓库(仓库名一般都是.git 结尾)
cd /srv
sudo mkdir -p repositories/sample.git
sudo git init --bare repositories/sample.git
把 owner 改为 gerrit,gerrit 要对该目录有读写权限才行
sudo chown -R gerrit:gerrit repositories
现在可以通过 git clone 命令克隆远程仓库
cd ~flinger
git clone gerrit@ubuntu:/srv/repositories/sample.git
git 配置一下(个人喜好,--global 表示对当前用户有效)
git config --global alias.st status
git config --global alias.br branch
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global core.editor vim
git config --global user.email "xxxxxx@yyyyyyglobal.com"
git config --global user.name "flinger"
注意,这里配置的邮箱要跟刚才生成 rsa 公钥私钥的那个邮箱一致
cd sample
touch hello.txt
vi hello.txt
随便编辑一下 hello.txt 的内容,保存退出
git add hello.txt
git commit
会启动 vi 编辑器,写一句注释:add a hello.txt file,保存退出
可以看一下 git log
git lg
由于远程库是空的,所以首次 push 需要加上-u 参数,之后就不用-u 参数了
git push -u origin master
这时你可以创建别的用户,也同样来 clone 一下这个 sample 仓库,模拟多人协作
我创建了一个 toby 用户,git clone 拉下来这个 sample project 后,更新了两笔 commit,push
到服务端
(注意:同样要把 toby 的 ssh 公钥添加到 git 用户的 authorized_keys)
用 toby 用户也添加了一条修改并提交了
这时在 finger 用户这边用 git pull 来拉到最新就可以看到 toby 用户的提交了
这 种 方 法 适 合 团 队 很 小 的 公 司 , 把 每 个 人 的 公 钥 收 集 起 来 放 到 服 务 器 的
/home/gerrit/.ssh/authorized_keys 文件里是可行的
安装最简单的网页版本管理系统——gitweb
参考:
https://blog.csdn.net/xl_name/article/details/79617652
安装 gitweb 和 apache2
cd ~flinger
sudo apt-get install apache2 apache2-utils git-core gitweb
修改配置文件(因为 gitweb 在/etc/apache2/conf.d/下安装了配置文件,但这个目录是过时的)
sudo cp /etc/apache2/conf.d/gitweb /etc/apache2/conf-available/gitweb.conf
cd /etc/apache2/conf-enabled/
sudo ln -s ../conf-available/gitweb.conf gitweb.conf
修改 gitweb.conf 如下:
sudo vi ../conf-available/gitweb.conf
在 FollowSymLinks 前面加上了"+"解决语法问题
使能 cgi:
ubuntu 中 gitweb cgi 脚本应该默认放在/usr/lib/cgi-bin/中,刚好和 apache2 默认的 cgi-bin 目录
一致
sudo a2enmod cgi
sudo service apache2 restart
修改/etc/gitweb.conf,添加上项目信息:
sudo vi /etc/gitweb.conf
$projectroot = "/srv/repositories";
$projects_list = $projectroot;
剩余20页未读,继续阅读
cfl927096306
- 粉丝: 144
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
- MW全能培训汽轮机调节保安系统PPT教学课件.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1