Jenkins+Github的持续集成环境跳转
[root@bogon var]# vim /etc/sysconfig/selinux
...
SELINUX=disabled
...
[root@bogon var]# reboot
[root@bogon ~]# yum -y install curl policycoreutils openssh-server openssh-clients postfx
[root@bogon ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[root@bogon ~]# systemctl start postfix && systemctl enable postfix
也可访问https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-11.9.6-ce.0.el7.x86_64.rpm下载
使用yum localinstall /路径/gitlab-ce-**.x86_64.rpm 安装
[root@bogon ~]# yum install -y gitlab-ce
创建ssl目录
[root@bogon opt]# mkdir -p /etc/gitlab/ssl
创建本地私有秘钥
[root@bogon opt]# openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048
Generating RSA private key, 2048 bit long modulus
......................................+++
.............................................+++
e is 65537 (0x10001)
创建私有csr证书
[root@bogon opt]# openssl req -new -key "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.csr"
...
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 []:[email protected] #输入邮箱
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456 #输入密码
An optional company name []:#直接回车
查看证书
[root@bogon ssl]# ll /etc/gitlab/ssl/
total 8
-rw-r--r-- 1 root root 1066 Apr 6 18:20 gitlab.example.com.csr
-rw-r--r-- 1 root root 1679 Apr 6 18:14 gitlab.example.com.key
接下来利用私有密钥和私有证书创建CRT签署证书
[root@bogon 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=bj/L=bj/O= /OU= /CN=gitlab.example.com/emailAddress=[email protected]
Getting Private key
[root@bogon ssl]# ls
gitlab.example.com.crt gitlab.example.com.csr gitlab.example.com.key
利用openssl命令输出pem证书
[root@bogon ssl]# openssl dhparam -out /etc/gitlab/ssl/dhparam.pem 2048
[root@bogon ssl]# ls
dhparam.pem gitlab.example.com.crt gitlab.example.com.csr gitlab.example.com.key
更改证书权限
[root@bogon ssl]# chmod 600 /etc/gitlab/ssl/*
[root@bogon ssl]# ll /etc/gitlab/ssl/
total 16
-rw------- 1 root root 424 Apr 6 18:30 dhparam.pem
-rw------- 1 root root 1265 Apr 6 18:27 gitlab.example.com.crt
-rw------- 1 root root 1066 Apr 6 18:20 gitlab.example.com.csr
-rw------- 1 root root 1679 Apr 6 18:14 gitlab.example.com.key
[root@bogon ssl]# cp /etc/gitlab/gitlab.rb{,.bak}
[root@bogon ssl]# vim /etc/gitlab/gitlab.rb
1.
将此行: external_url 'http://gitlab.example.com'
改为: external_url 'https://gitlab.example.com'
2.
将此行: # nginx['redirect_http_to_https'] = false
改为(并去掉注释): nginx['redirect_http_to_https'] = true
3.
将此2行:
# nginx['ssl_certificate'] = "/etc/gitlab/ssl/#{node['fqdn']}.crt"
# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/#{node['fqdn']}.key"
改为:
# nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"
# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"
4.
将此行: # nginx['ssl_dhparam'] = nil # Path to dhparams.pem, eg. /etc/gitlab/ssl/dhparams.pem
改为: # nginx['ssl_dhparam'] = /etc/gitlab/ssl/dhparam.pem # Path to dhparams.pem, eg. /etc/gitlab/ssl/dhparams.pem
[root@bogon ssl]# gitlab-ctl reconfigure
.........
Running handlers:
Running handlers complete
Chef Client finished, 473/1268 resources updated in 06 minutes 49 seconds
gitlab Reconfigured! #到此处说明安装完成
[root@bogon ssl]# cp /var/opt/gitlab/nginx/conf/gitlab-http.conf{,.bak}
[root@bogon ssl]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
在此行下: server_name gitlab.example.com;
添加: rewrite ^(.*)$ https://$host$1 permanent;
重启使加载配置
[root@bogon ssl]# gitlab-ctl restart
转载自:https://www.cnblogs.com/zd520pyx1314/p/10210727.html