搭建gitlab

发布时间 2023-12-29 15:17:13作者: _林鹿

搭建GitLab(yum安装)

一、安装gitlab epel源

vi /etc/yum.repos.d/gitlab.repo
输入以下内容

[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
Repo_gpgcheck=0
Enabled=1
gpgcheck=0

重新创建元数据缓存
yum clean all && yum makecache
查看所有可安装的gitlab-ce版本
yum list gitlab-ce --showduplicates
安装gitlab-ce
yum -y install gitlab-ce-16.6.2-ce.0.el7
启动gitlab-ce
gitlab-ctl start

二、修改gitlab配置支持https和ip访问限制

yum安装的gitlab默认配置文件为/etc/gitlab/gitlab.rb

修改配置文件内容如下图所示
image
external_urlgitlab域名
nginx['redirect_http_to_https']重定向http到https
nginx['ssl_certificate']SSL证书位置
nginx['ssl_certificate_key']SSL密钥位置
nginx['custom_gitlab_server_config']IP访问限制

nginx默认配置文件为/var/opt/gitlab/nginx/conf/gitlab-http.conf

修改配置文件中的https设置
image

重新加载配置文件并重新启动

gitlab-ctl reconfigure
gitlab-ctl restart