暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Centos7 Gitlab安装配置超详细

原创 运维匠之陆陆爸 2022-08-12
794

文章目录
Gitlba 安装配置流程
一、环境准备
1.1 关闭系统自带的Firewalld防火墙
1.2 关闭SElinux
1.3 重启centos
二、yum 安装git需要的依赖包
三、 下载gitlab的yum源仓库地址
四、安装Gitlab(二选一)
4.1 yum安装
4.2 源码安装
五、启动postfix并开机自启
六、 使用openssl命令创建gitlab本地证书,并配置config
6.1 创建ssl目录
6.2 创建本地私有秘钥
6.3 使用刚才创建的私有秘钥创建csr证书
6.4 使用私有秘钥、csr证书创建crt签署证书
6.5 使用openssl命令输出pem证书
6.6 为了安全,修改秘钥证书等文件的权限
七、 修改gitlab配置文件(以下操作全部在vi编辑器中)
八、 初始化gitlab配置
九、 更改gltlab下nginx代理工具配置
十、 重启gitlab
十一、修改本地windows电脑的hosts文件,添加域名映射关系
浏览器访问
Gitlba 安装配置流程
一、环境准备
1.1 关闭系统自带的Firewalld防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
1
2
1.2 关闭SElinux
vim /etc/sysconfig/selinux
...
SELINUX=disabled
...
1
2
3
4
1.3 重启centos
reboot
1
二、yum 安装git需要的依赖包
yum install -y curl policycoreutil openssh-server openssh-clients postfix
1
三、 下载gitlab的yum源仓库地址
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

1
2
四、安装Gitlab(二选一)
4.1 yum安装
yum -y install gitlab-ce
1
备注:只写gitlab-ce下载的就是最新版,如需指定版本请写全版本号
4.2 源码安装
清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

rpm -ivh gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
1
五、启动postfix并开机自启
systemctl start postfix
systemctl enable postfix
1
2
六、 使用openssl命令创建gitlab本地证书,并配置config
6.1 创建ssl目录
基于NFS实现的storageclass二进制部署文件和镜像
zip

0星
超过10%的资源
12.29MB

下载
mkdir -p /etc/gitlab/ssl
1
6.2 创建本地私有秘钥
openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048
1
6.3 使用刚才创建的私有秘钥创建csr证书
openssl req -new -key "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.csr"
1
[root@gitlab ~]# 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
State or Province Name (full name) []:bj
Locality Name (eg, city) [Default City]:bj
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 []:admin@example.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:
[root@gitlab ~]#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
6.4 使用私有秘钥、csr证书创建crt签署证书
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"
1
6.5 使用openssl命令输出pem证书
openssl dhparam -out /etc/gitlab/ssl/dhparams.pem 2048
1
6.6 为了安全,修改秘钥证书等文件的权限
chmod 600 /etc/gitlab/ssl/*
1
七、 修改gitlab配置文件(以下操作全部在vi编辑器中)
Ansible-ansible-role-k8s_manifests.zip
.zip

0星
超过10%的资源
9KB

下载
vim /etc/gitlab/gitlab.rb
:set nu 开启行号
# 定位13行,修改external_url的值
13 external_url 'https://gitlab.example.com'

# 定位811行,解开注释并将false改为true
811 nginx['redirect_http_to_https'] = true

# 定位823和824行,修改csr和key的文件路径
823 # nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"
824 # nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"

# 定位838行,修改dhparam.pem文件路径
838 # nginx['ssl_dhparam'] = /etc/gitlab/ssl/dhparams.pem # Path to dhparams.pem, eg. /etc/gitlab/ssl/dhparams.pem

# 修改完毕保存退出
:wq

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
八、 初始化gitlab配置
gitlab-ctl reconfigure
1
九、 更改gltlab下nginx代理工具配置
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

# 搜索server_name,在下面一行添加以下内容
rewrite ^(.*)$ https://$host$1 permanent;
1
2
3
4
......省略部分内容
## Redirects all HTTP traffic to the HTTPS host
server {
listen *:80;
server_name gitlab.example.com;
rewrite ^(.*)$ https://$host$1 permanent;
server_tokens off; ## Don't show the nginx version number, a security best practice
return 301 https://gitlab.example.com:443$request_uri;
access_log /var/log/gitlab/nginx/gitlab_access.log gitlab_access;
error_log /var/log/gitlab/nginx/gitlab_error.log;
}
......省略部分内容
1
2
3
4
5
6
7
8
9
10
11
12
十、 重启gitlab
gitlab-ctl restart
1
十一、修改本地windows电脑的hosts文件,添加域名映射关系

IP地址按自己的修改

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论