Gitlab搭建详细步骤

这篇具有很好参考价值的文章主要介绍了Gitlab搭建详细步骤。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Gitlab的概念

       GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。安装方法是参考GitLab在GitHub上的Wiki页面。Gitlab是目前被广泛使用的基于git的开源代码管理平台, 基于Ruby on Rails构建, 主要针对软件开发过程中产生的代码和文档进行管理, Gitlab主要针对group和project两个维度进行代码和文档管理, 其中group是群组, project是工程项目, 一个group可以管理多个project, 可以理解为一个群组中有多项软件开发任务, 而一个project中可能包含多个branch, 意为每个项目中有多个分支, 分支间相互独立, 不同分支可以进行归并。

  定义

      GitLab是由GitLabInc.开发,使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。

 用到的git指令

git init :初始化.git文件夹
git add 文件名:从本地工作区添加文件入暂存区
git add -A:从本地工作区添加全部文件入暂存区
git commit -m “添加的备注” 文件名:暂存区给文件备注确认,记录为一个版本
git commit -m “添加的备注” 文件名:暂存区全部文件备注确认,记录为一个版本
git log:查看历史版本记录
git status:查看文档修改记录,红色为未add内容,绿色为可以commit内容
git push 地址名 本地分支:远程库分支:将暂存区代码推入远程库
git remove add 地址名 地址url:远程库操作
git branch -M 分支名:创建分支

gitlab的安装与配置

gitlab-ce.repo源包

vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1


#yum makecache

或者这样装wget安装

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm

改主机域名

[root@localhost ~]# hostnamectl set-hostname gitlab.example.com
[root@localhost ~]# bash
[root@gitlab ~]# 

配置 hosts

[root@gitlab ~]# cat /etc/hosts
192.168.100.17   gitlab.example.com

安装gitlab依赖软件 及获取 GPG 密钥

yum install -y curl policycoreutils openssh-server openssh-clients postfix

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

安装 postfix 并启动

yum install postfix
systemctl start postfix
systemctl enable  postfix 

安装gitlab-ce 

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum -y install gitlab-ce

手动配置ssl证书

1.创建私有密钥

[root@gitlab ~]# mkdir -p /etc/gitlab/ssl
[root@gitlab ~]# openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048
Generating RSA private key, 2048 bit long modulus
...+++
........................................+++
e is 65537 (0x10001)

2.创建私有证书

[root@gitlab ~]# cd /etc/gitlab/ssl
[root@gitlab ssl]# ls
gitlab.example.com.key
[root@gitlab ssl]# openssl req -new -key "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.csr"
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN          CN  ##国家
State or Province Name (full name) []:SX      SX   ##省份
Locality Name (eg, city) [Default City]:XA    XA   ##城市  
Organization Name (eg, company) [Default Company Ltd]:    ##空格
Organizational Unit Name (eg, section) []:                ##空格
Common Name (eg, your name or your server's hostname) []:gitlab.example.com    
Email Address []:123456@qq.com                 ##邮箱地址

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456                ## 密码
An optional company name []:                  ##空格
[root@gitlab ssl]# ls
gitlab.example.com.csr  gitlab.example.com.key

 3.创建CRT签署证书

安装完成,创建好了ssl密钥和证书
在ssl目录下ll
可以看到ssl密钥和证书
利用ssl密钥和证书创建签署证书

[root@gitlab ssl]# openssl x509 -req -days 365 -in "/etc/gitlab/ssl/gitlab.example.com.csr" -signkey "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.crt"
Signature ok
subject=/C=CN/ST=SX/L=XA/O=Default Company Ltd/CN=gitlab.example.com/emailAddress=123456@qq.com
Getting Private key
[root@gitlab ssl]# ll /etc/gitlab/ssl/
总用量 12
-rw------- 1 root root 1273 8月   8 15:52 gitlab.example.com.crt
-rw------- 1 root root 1070 8月   8 15:52 gitlab.example.com.csr
-rw------- 1 root root 1679 8月   8 15:50 gitlab.example.com.key

4.利用openssl签署pem 证书

root@gitlab ssl]# openssl x509 -req -days 365 -in "/etc/gitlab/ssl/gitlab.example.com.csr" -signkey "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.crt"
Signature ok
subject=/C=CN/ST=SX/L=XA/O=Default Company Ltd/CN=gitlab.example.com/emailAddress=123456@qq.com
Getting Private key
[root@gitlab ssl]# 
[root@gitlab ssl]# openssl dhparam -out /etc/gitlab/ssl/dhparams.pem  2048
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
..............................+..............................................................................................................................................................................................................................+.+..........................................................+...........................................................................................................................................+...........................................................................................................................................................................................................................................................+.....................................................................................+.........................................

5.更改ssl下的所有证书权限

[root@gitlab ssl]# chmod 600 *
[root@gitlab ssl]# ll
总用量 16
-rw------- 1 root root  424 8月   8 15:53 dhparams.pem
-rw------- 1 root root 1273 8月   8 15:52 gitlab.example.com.crt
-rw------- 1 root root 1070 8月   8 15:52 gitlab.example.com.csr
-rw------- 1 root root 1679 8月   8 15:50 gitlab.example.com.key

6.配置证书到gitlab配置文件中

[root@gitlab ssl]# vim /etc/gitlab/gitlab.rb 
external_url 'https://gitlab.example.com'      ###改为https开头
nginx['redirect_http_to_https'] = true           ###取消#号更改注释并为true  1397行
# nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"     ###更改路径
# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"     ###更改路径
# nginx['ssl_dhparam'] = "/etc/gitlab/ssl/dhparams.pem"   ##更改路径###   # Path to dhparams.pem, eg.  /etc/gitlab/ssl/dhparams.pem

7.更改完之后初始化命令执行

[root@gitlab ssl]# gitlab-ctl reconfigure  
....
....
....
Running handlers:
[2022-08-09T15:04:10+08:00] INFO: Running report handlers
Running handlers complete
[2022-08-09T15:04:10+08:00] INFO: Report handlers complete
Infra Phase complete, 3/818 resources updated in 13 seconds
gitlab Reconfigured!      
# 出现这个表示配置没有问题!

[root@gitlab ssl]# gitlab-ctl status
[root@gitlab ssl]#gitlab-ctl restart    
ok: run: alertmanager: (pid 16197) 0s
ok: run: gitaly: (pid 16212) 0s
ok: run: gitlab-exporter: (pid 16225) 0s
ok: run: gitlab-kas: (pid 16227) 0s
ok: run: gitlab-workhorse: (pid 16236) 1s
ok: run: grafana: (pid 16243) 0s
ok: run: logrotate: (pid 16253) 1s
ok: run: nginx: (pid 16260) 0s
ok: run: node-exporter: (pid 16269) 1s
ok: run: postgres-exporter: (pid 16281) 0s
ok: run: postgresql: (pid 16371) 0s
ok: run: prometheus: (pid 16384) 1s
ok: run: puma: (pid 16399) 0s
ok: run: redis: (pid 16405) 1s
ok: run: redis-exporter: (pid 16411) 0s
ok: run: sidekiq: (pid 16419) 0s
[root@gitlab conf]# 
[root@gitlab conf]#  gitlab-ctl restart sidekiq 
ok: run: sidekiq: (pid 17327) 0s

8.对nginx配置

[root@gitlab ssl]#cd /var/opt/gitlab/nginx/conf
[root@gitlab conf]# ls
gitlab-health.conf  gitlab-http.conf  nginx.conf  nginx-status.conf
[root@gitlab conf]# vim gitlab-http.conf  
server_name gitlab.example.com;
rewrite ^(.*)$ https://$host$1 permanent;      ####需要添加的配置 注:(配置在80端口)

9.重启gitlab

[root@gitlab ssl]#  gitlab-ctl restart 
ok: run: alertmanager: (pid 15710) 0s
ok: run: gitaly: (pid 15723) 1s
ok: run: gitlab-exporter: (pid 15736) 0s
ok: run: gitlab-kas: (pid 15738) 0s
ok: run: gitlab-workhorse: (pid 15747) 1s
ok: run: grafana: (pid 15755) 0s
ok: run: logrotate: (pid 15765) 1s
ok: run: nginx: (pid 15775) 0s
ok: run: node-exporter: (pid 15781) 1s
ok: run: postgres-exporter: (pid 15792) 0s
ok: run: postgresql: (pid 15800) 0s
ok: run: prometheus: (pid 15803) 0s
ok: run: puma: (pid 15895) 0s
ok: run: redis: (pid 15904) 1s
ok: run: redis-exporter: (pid 15910) 0s
ok: run: sidekiq: (pid 15918) 0s

在Windows系统里C:\Windows\System32\drivers\etc\hosts 添加以下

192.168.100.17        gitlab.example.com

然后ping gitlab.example.com   是否能通

浏览器登录 gitlab    机器配置要大于4g内存,否则很容易启动不了,报502

gitlab搭建,git,运维,git,linux,centos,服务器

浏览器登录 gitlab    https://gitlab.example.com/

gitlab搭建,git,运维,git,linux,centos,服务器

 查看初始密码

[root@gitlab ~]# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: hms9K6+y9yBlIj1UgLcjmbQ5c1mFF/EHMaFQALPjNHQ=       ##为初始密码

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
[root@gitlab ~]# 

gitlab切换中文模式 

gitlab搭建,git,运维,git,linux,centos,服务器

 更改初始密码

gitlab搭建,git,运维,git,linux,centos,服务器

开始使用gitlab创建项目

gitlab搭建,git,运维,git,linux,centos,服务器

1,创建一个测试项目 

gitlab搭建,git,运维,git,linux,centos,服务器

2,复制仓库地址 

gitlab搭建,git,运维,git,linux,centos,服务器

生成公钥私钥对出来,命令:ssh-keygen

进入密钥目录:cd .ssh/

[root@gitlab ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:tfCPmmz4NkdfloxsUjyfkO1eS6t7b81iqGw0KQKR26E root@gitlab.example.com
The key's randomart image is:
+---[RSA 2048]----+
|     .           |
|    o .          |
|     = .. .. o   |
|    E .  + .* .  |
|     .  S o+ B o |
|      . . *o+ O..|
|       o +.=.=.o+|
|      ..++o o +++|
|       +=+o. ++oo|
+----[SHA256]-----+
[root@gitlab ~]# cd .ssh/
[root@gitlab .ssh]# ll
总用量 8
-rw------- 1 root root 1675 8月  10 09:44 id_rsa
-rw-r--r-- 1 root root  405 8月  10 09:44 id_rsa.pub
[root@gitlab .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFJIIh+4WbYDsmSr+ZdY1DTo9DHhpIuBjRghEGagYVWg3KgnjhC3Ic7nt9opH2AHHAnVqg84FIkBpzbeb0zAwaam0I6fEeXC2h2r7XEWrfDWt81N6QwV6hujG3tzL3hggFTVa3SWU8tVCQbjC9qUYrHvj+oU+m4iXjXqPYxo9piBGXvJovte28Izy36hk21jp9c0Qx6eAAFGX1t762s4DZyAXD5UH3EQwz6y9hMvbn7o+P2uNb8QDbcR4Luhl0TO89SISftBI81ABd+9ej+K9SsQNO1vk6yV2EAqKr662ErM76lktmyZPuofBtoLOpH2pL0xPx5d2xIplhzt5Tfrk1 root@gitlab.example.com
[root@gitlab .ssh]# 

新建一个SSH密钥

gitlab搭建,git,运维,git,linux,centos,服务器

gitlab搭建,git,运维,git,linux,centos,服务器文章来源地址https://www.toymoban.com/news/detail-839874.html

到了这里,关于Gitlab搭建详细步骤的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • GitLab+Jenkins搭建DevOps一体化运维平台

    ​ 大家拿到代码后,要如何运行呢?导入IDEA,然后启动?开发过程可定没有问题,那生产环境呢?在现在互联网大环境下,越来越要求开发运维一体化。如果对于企业级的项目管理方式不了解,那么开发工作将举步维艰。这一节课主要带大家快速理解一下电商项目的运维部

    2024年02月09日
    浏览(39)
  • 一、Docker部署GitLab(详细步骤)

    docker安装教程:https://qingsi.blog.csdn.net/article/details/131270071 注意:接下来的配置请在容器内进行修改,不要在挂载到宿主机的文件上进行修改。否则可能出现配置更新不到容器内,或者是不能即时更新到容器内,导致gitlab启动成功,但是无法访问 修改完成之后保存退出即可,

    2024年04月09日
    浏览(83)
  • DevOps搭建(四)-GitLab安装细步骤

    在这里我们用docker安装 进入该目录 输入以下内容保存 查看启动日志 稍等片刻,如果没看到错误日志,证明已经正常启动。 开放GitLab对应的端口 重启防火墙 GitLab的默认登录账号为root,密码需要进入docker容器中获取。 6.1、获取root账号登录密码 进入gitlab容器: 获取密码 复制

    2024年02月04日
    浏览(29)
  • GitLab仓库管理系统安装详细步骤

    本案例安装 gitlab、jenkins、并部署springboot应用程序,所以准备了3台服务器。 注意:以上springboot项目中用到的java版本与服务器2,服务器3中安装的一致 我虚拟机模拟搭建时版本如下: jdk : jdk-11.0.16.1 maven : 3.8.6 jenkins : Jenkins 2.361.4 LTS springboot : 2.7.1 gitlab中文官网 英文官网 官方

    2024年02月08日
    浏览(34)
  • 【gitlab部署】centos8安装gitlab(搭建属于自己的代码服务器)

    在团队开发过程中,想要拥有高效的开发效率,选择一个好的 代码开发工具 是必不可少的。搭建git服务器有两种方式 ● github(国外的,很卡)或者gitee(国内的,网速还可以,可以设置项目为私有,防止其他人可见) ● 通过gitlab搭建自己的git服务器 要求 ● gitlab十分吃内存,建议

    2024年02月11日
    浏览(38)
  • 本地项目如何上传到Gitlab详细过程步骤

    目录 本地项目上传到Gitlab 第一步:打开gitlab新建一个仓库springboot-rabbitmq: 第二步:找到本地文件,右键点击Git Bash Here。  第三步:初始化本地仓库:  第四步:将当前目录下所有的修改或新增的文件添加到暂存区 第五步:用于将暂存中的更改创建为一次提交 第六步:建立

    2024年02月14日
    浏览(34)
  • 如何在 Linux CentOS 8 中搭建 GitLab 私有仓库并结合 Cpolar 内网穿透工具实现公网访问私有仓库【无公网IP内网穿透】

    📱iOS学霸主页 在强者的眼中,没有最好,只有更好。我们是移动开发领域的优质创作者,同时也是阿里云专家博主。 ✨ 关注我们的主页,探索iOS开发的无限可能! 🔥我们与您分享最新的技术洞察和实战经验,助您在移动应用开发领域取得成功。 📌欢迎访问我们的微信公

    2024年02月12日
    浏览(52)
  • gitLab git merge request 请求合并注意事项及步骤

       在项目的分支下选择Merge request  进入合并分支的选项操作 注意选择需要合并到的分支版本 选择处理人 就可以提交分支  1 GitLab合并请求时出现 Validate branchesCannot Create: This merge request already existed 报错原因该分支上一个合并请求还存在 应该先close掉该分支的上一个合并请

    2024年02月16日
    浏览(38)
  • 2023最新Ubuntu安装部署Gitlab详细教程(每个步骤均配图)

    打开终端,运行如下命令: 接下来会遇到如下界面,Tab切换到“确定”按钮,然后回车。 还是照样Tab切换到“确定”按钮,然后回车。 先执行命令 curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash (我这里不小心执行了两次,一次即可) 前往Git

    2024年02月14日
    浏览(33)
  • 【Git版本控制】以及搭建gitlab服务

    Git是一个免费、开源的分布式版本控制系统,它因其速度快、灵活性高和强大的分支管理能力而广受欢迎。分布式版本控制系统中,每个开发者都拥有完整的代码仓库,包含完整的历史记录。开发者可以在本地进行版本控制操作,不需要始终依赖中央服务器。 git的下载:http

    2024年02月20日
    浏览(25)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包