gitlab安装教程

GitLab详细安装教程

GitLab是一个开源的用于仓库管理的项目,使用Git作为代码管理工具,大家应该都知道也使用过github这个网站吧,这两个看起来非常的相似,他们有什么区别呢?
GitHub作为开源代码库,拥有超过 900 万的开发者用户,目前仍然是最火的开源项目托管平台,GitHub 同时提供公共仓库和私有仓库,但如果使用私有仓库,是需要付费的。GitLab 解决了这个问题,你可以在上面创建私人的免费仓库。
GitLab 让开发团队对他们的代码仓库拥有更多的控制,相比较 GitHub , 它有不少特色:
(1) 允许免费设置仓库权限;
(2) 允许用户选择分享一个 project 的部分代码;
(3) 允许用户设置 project 的获取权限,进一步提升安全性;
(4) 可以设置获取到团队整体的改进进度;
(5) 通过 innersourcing 让不在权限范围内的人访问不到该资源;
所以,从代码的私有性上来看,GitLab 是一个更好的选择。但是对于开源项目而言,GitHub 依然是代码托管的首选。

部署GitLab

环境配置

虚拟机 :VMware Workstation 15
主机名 :gitlab.example.com
IP地址 :192.168.0.102
系统版本 :CentOS Linux release 7.5.1804
内核版本:3.10.0-862.el7.x86_64
除此之外,还要在宿主机win10系统下的C:\Windows\System32\drivers\etc\hosts文件中添加如下内容
192.168.0.102 gitlab.example.com
官网硬件需求:

防止干扰实验,关闭selinux和防火墙后重启
[root@gitlab ~]# sed -i "s/enforcing/disabled/" /etc/selinux/config
[root@gitlab ~]# systemctl stop firewalld && systemmctl disable firewalld
[root@gitlab ~]# reboot
安装postfix并设置开机自启(新用户激活邮件用到)
[root@gitlab ~]# yum install postfix
[root@gitlab ~]# systemctl start postfix && systemctl enable postfix
安装gitlab组件
[root@gitlab ~]# yum install curl policycoreutils openssh-server openssh-clients
配置yum仓库
[root@gitlab ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安装社区版gitlab
[root@gitlab ~]# yum install -y gitlab-ce
也可以去https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm下载rpm包安装

gitlab相关配置初始化并完成安装

证书创建和加载配置

创建文件夹存放证书、key

[root@gitlab ~]# mkdir /etc/gitlab/ssl  

[root@gitlab ~]# cd /etc/gitlab/ssl/

创建私有密钥 

[root@gitlab ssl]# openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048     //直接回车即可

 创建私有证书

[root@gitlab ssl]# openssl req -new -key "gitlab.example.com.key" -out "gitlab.example.com.csr"

用私有密钥和私有证书创建CRT签署证书

[root@gitlab ssl]# openssl x509 -req -days 365 -in "gitlab.example.com.csr" -signkey "gitlab.example.com.key" -out "gitlab.example.com.crt"

openssl命令生成pem证书,需要花点时间

[root@gitlab ssl]# openssl dhparam -out dhparams.pem 2048

查看前面生成的证书

修改证书文件权限

[root@gitlab ssl]# chmod 600 *

gitlab配置

备份gitlab配置文件

 [root@gitlab gitlab]# cp -a /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak

更改配置文件/etc/gitlab/gitlab.rb

vim /etc/gitlab/gitlab.rb

 

初始化gitlab相关服务配置

[root@gitlab ~]# gitlab-ctl reconfigure

nginx配置,备份配置文件

[root@gitlab ~]# cp -a /var/opt/gitlab/nginx/conf/gitlab-http.conf /var/opt/gitlab/nginx/conf/gitlab-http.conf.bak

[root@gitlab ~]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

 重启gitlab

[root@gitlab ~]# gitlab-ctl restart

所有服务重启成功

打开浏览器访问gitlab.example.com,访问gitlab的web页面,安装成功

 

posted @ 2020-02-06 15:01  w_boy  阅读(1787)  评论(0编辑  收藏  举报