iis服务器助手广告广告
返回顶部
首页 > 资讯 > 服务器 >Gitlab搭建详细步骤
  • 664
分享到

Gitlab搭建详细步骤

运维gitlinuxcentos服务器 2023-09-04 17:09:58 664人浏览 泡泡鱼
摘要

gitlab的概念        GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的WEB服务。安装方法是参考GitLab在GitHub上的Wiki页面。Gitlab是目前被广泛使用的基于gi

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 Repositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpGCheck=0enabled=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/hosts192.168.100.17   gitlab.example.com

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

yum install -y curl policycoreutils openssh-server openssh-clients postfixrpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-Centos-7

安装 postfix 并启动

yum install postfixsystemctl start postfixsystemctl enable  postfix 

安装gitlab-ce 

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bashyum -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" 2048Generating RSA private key, 2048 bit long modulus...+++........................................+++e is 65537 (0x10001)

2.创建私有证书

[root@gitlab ~]# cd /etc/gitlab/ssl[root@gitlab ssl]# lsgitlab.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 incorporatedinto 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 blankFor 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' attributesto be sent with your certificate requestA challenge passWord []:123456                ## 密码An optional company name []:                  ##空格[root@gitlab ssl]# lsgitlab.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 oksubject=/C=CN/ST=SX/L=XA/O=Default Company Ltd/CN=gitlab.example.com/emailAddress=123456@qq.comGetting 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 oksubject=/C=CN/ST=SX/L=XA/O=Default Company Ltd/CN=gitlab.example.com/emailAddress=123456@qq.comGetting Private key[root@gitlab ssl]# [root@gitlab ssl]# openssl dhparam -out /etc/gitlab/ssl/dhparams.pem  2048Generating DH parameters, 2048 bit long safe prime, generator 2This 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 handlersRunning handlers complete[2022-08-09T15:04:10+08:00] INFO: Report handlers completeInfra Phase complete, 3/818 resources updated in 13 secondsgitlab Reconfigured!      # 出现这个表示配置没有问题![root@gitlab ssl]# gitlab-ctl status[root@gitlab ssl]#gitlab-ctl restart    ok: run: alertmanager: (pid 16197) 0sok: run: gitaly: (pid 16212) 0sok: run: gitlab-exporter: (pid 16225) 0sok: run: gitlab-kas: (pid 16227) 0sok: run: gitlab-workhorse: (pid 16236) 1sok: run: grafana: (pid 16243) 0sok: run: logrotate: (pid 16253) 1sok: run: nginx: (pid 16260) 0sok: run: node-exporter: (pid 16269) 1sok: run: postgres-exporter: (pid 16281) 0sok: run: postgresql: (pid 16371) 0sok: run: prometheus: (pid 16384) 1sok: run: puma: (pid 16399) 0sok: run: Redis: (pid 16405) 1sok: run: redis-exporter: (pid 16411) 0sok: 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]# lsgitlab-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) 0sok: run: gitaly: (pid 15723) 1sok: run: gitlab-exporter: (pid 15736) 0sok: run: gitlab-kas: (pid 15738) 0sok: run: gitlab-workhorse: (pid 15747) 1sok: run: grafana: (pid 15755) 0sok: run: logrotate: (pid 15765) 1sok: run: nginx: (pid 15775) 0sok: run: node-exporter: (pid 15781) 1sok: run: postgres-exporter: (pid 15792) 0sok: run: postgresql: (pid 15800) 0sok: run: prometheus: (pid 15803) 0sok: run: puma: (pid 15895) 0sok: run: redis: (pid 15904) 1sok: run: redis-exporter: (pid 15910) 0sok: 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    https://gitlab.example.com/

 查看初始密码

[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创建项目

1,创建一个测试项目 

2,复制仓库地址 

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

进入密钥目录:cd .ssh/

[root@gitlab ~]# ssh-keygenGenerating 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.comThe 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密钥

来源地址:https://blog.csdn.net/qq_15290209/article/details/126230624

--结束END--

本文标题: Gitlab搭建详细步骤

本文链接: https://www.lsjlt.com/news/393922.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Gitlab搭建详细步骤
    Gitlab的概念        GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。安装方法是参考GitLab在GitHub上的Wiki页面。Gitlab是目前被广泛使用的基于gi...
    99+
    2023-09-04
    运维 git linux centos 服务器
  • centos搭建Gitlab的详细步骤(分享)
    随着软件开发的不断发展,代码版本控制成为了任何一个软件开发团队的必备工具。Gitlab作为一款免费、开源、易于安装和管理的代码管理平台已经广泛应用于各个开发团队中。本文将介绍在CentOS系统上搭建Gitlab的详细步骤。准备工作在开始安装...
    99+
    2023-10-22
  • mac上怎么搭建gitlab服务器?详细步骤分享
    GitLab是一款强大的源代码管理工具,可以让团队协作更加高效。在Mac电脑上搭建GitLab服务器,可以让团队成员更加方便地进行代码共享和协作。本文将介绍在Mac电脑上搭建GitLab服务器的详细步骤。一、安装必要的软件在Mac电脑上搭建...
    99+
    2023-10-22
  • docker搭建memcached的详细步骤
    目录搭建步骤worker登录机器新建文件夹下载magent-0.5.tar.gz并安装创建Dockerfile并构建镜像构建镜像magent:v1pull memcached镜像手动...
    99+
    2022-11-13
  • centos6搭建gitlab的方法步骤
    前言 原来的项目放在公网的gitlab上,处于安全考虑,在内网搭建一套,有图形界面,可以直接从外网git导入进来,使用了一下觉得挺方便,把安装流程记录下来,参考官网:https://gitlab.com/gitlab-o...
    99+
    2022-06-04
    centos6搭建gitlab centos搭建gitlab
  • 搭建Python Web环境的详细步骤
    这篇文章主要介绍“搭建Python Web环境的详细步骤”,在日常操作中,相信很多人在搭建Python Web环境的详细步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”搭建Python Web环境的详细步骤...
    99+
    2023-06-17
  • MySQL搭建主从复制详细步骤
    下面讲讲关于MySQL搭建主从复制详细步骤,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完MySQL搭建主从复制详细步骤这篇文章你一定会有所受益。搭建MySQL主从复制需要提前准...
    99+
    2022-10-18
  • 搭建redis+mysql架构的详细步骤
    下面一起来了解下搭建redis+mysql架构的详细步骤,相信大家看完肯定会受益匪浅,文字在精不在多,希望搭建redis+mysql架构的详细步骤这篇短内容是你想要的。redis+mysql框架搭建&nbs...
    99+
    2022-10-18
  • MySQL中搭建ProxySQL Cluster的详细步骤
    下文给大家带来关于MySQL中搭建ProxySQL Cluster的详细步骤,感兴趣的话就一起来看看这篇文章吧,相信看完MySQL中搭建ProxySQL Cluster的详细步骤对大家多少有点帮助吧。环境:...
    99+
    2022-10-18
  • 在CentOS中搭建Hadoop的详细步骤
    搭建说明:第一次搭建 Hadoop 的小伙伴,请严格按照文章中的软件环境和步骤搭建,不一样的版本都可能会导致问题。 软件环境: 虚拟机:VMware Pro14 linux:CentOS-6.4(下载地址,下载DVD版本...
    99+
    2022-06-04
    CentOS搭建Hadoop CentOS Hadoop搭建
  • VScode搭建OpenCV环境的详细步骤
    目录安装MinGW-w64安装CMake生成MakeFiles编译OpencvVScode配置  用vscode来写opencv代码需要自己编译OpenCV,主要用到MinGW-w6...
    99+
    2022-11-12
  • Git服务器的详细搭建步骤
    这篇文章主要介绍“Git服务器的详细搭建步骤”,在日常操作中,相信很多人在Git服务器的详细搭建步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Git服务器的详细搭建步骤”的疑惑有所帮助!接下来,请跟着小编...
    99+
    2023-06-04
  • Docker 部署 Gitlab 服务器(详细步骤)
    目录         Gitlab镜像 1、拉取Gitlab镜像 2、启动Gitlab容器  3、修改配置 4、浏览器访问  5、修改root密码 6、gitlab操作 Gitlab镜像 1、拉取Gitlab镜像 docker pul...
    99+
    2023-09-06
    docker
  • RHEL搭建FTP服务器的详细步骤
    这篇文章主要介绍“RHEL搭建FTP服务器的详细步骤”,在日常操作中,相信很多人在RHEL搭建FTP服务器的详细步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”RHEL搭建FTP服务器的详细步骤”的疑惑有所...
    99+
    2023-06-17
  • hadoop伪分布模式搭建(详细步骤)
    一、前期准备 1. 关闭防火墙 2. 安装好JDK 3. 准备hadoop安装包 二、安装hadoop伪分布模式 1. 在home/hadoop/software/路径下创建hadooptmp目录 2. 解压hadoop-3.3.0.ta...
    99+
    2023-09-20
    hadoop 大数据 服务器
  • 搭建Redis服务器步骤详细介绍
    目录安装Redis 配置redis.config测试登录可视化redis软件redis命令行中文乱码安装Redis 我的安装包在 tar -zxvf redis-6.2.6.t...
    99+
    2022-11-12
  • eclipse搭建android开发环境详细步骤
    搭建android应用的开发环境,一套程序下来也是相当繁琐的,这里我整理下一整套详细流程: 1,下载JDK 去oracle官网下载最新版本的jdk,官网地址 http://ww...
    99+
    2022-06-06
    环境 Eclipse android开发 Android
  • 搭建 Selenium+Python开发环境详细步骤
    目录一、写在前面二、环境搭建1、Python环境搭建2、第一个脚本3、可能遇到的问题4、解决办法5、运行效果三、写在最后一、写在前面 我从未想过自己会写python系列的自动化文章,...
    99+
    2022-11-11
  • vite的搭建与使用的详细步骤
    目录1.安装:2.在vite项目中使用TypeScript3.vite项目使用less sass scss 4.vite打包5.下面就来创建一个标准的项目实际开发中编写的代...
    99+
    2022-11-13
  • linux搭建ldap服务器的详细步骤
    本篇内容介绍了“linux搭建ldap服务器的详细步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!安装openldap-servers软件...
    99+
    2023-06-13
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作