#配置要求:2GB内存 2核CPU 以上
# 关闭selinux
[root@jenkins ~]# sed -i 's#enforcing#disabled#g' /etc/sysconfig/selinux
# 临时关闭
[root@jenkins ~]# setenforce 0
#安装依赖
[root@jenkins ~]# yum install -y curl policycoreutils-python openssh-server perl postfix
#安装 Postfix 以发送通知电子邮件
[root@jenkins ~]# yum install postfix
[root@jenkins ~]# systemctl enable --now postfix
#下载gitlab安装包(清华大学源镜像站)
[root@jenkins ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.9.7-ce.0.el7.x86_64.rpm
[root@jenkins ~]# yum install -y gitlab-ce-13.9.7-ce.0.el7.x86_64.rpm
#配置域名
[root@jenkins ~]# echo 10.0.0.91 www.zzcweb.top >> /etc/hosts
#上传证书压缩包
[root@jenkins ~]# mkdir /etc/gitlab/ssl
[root@jenkins /etc/gitlab/ssl]# unzip zzcweb.top.zip
[root@jenkins /etc/gitlab/ssl]# ll
drwxr-xr-x 2 root root 79 Nov 16 15:20 Apache
drwxr-xr-x 2 root root 28 Nov 16 15:20 IIS
drwxr-xr-x 2 root root 61 Nov 16 15:20 Nginx
drwxr-xr-x 2 root root 28 Nov 16 15:20 Tomcat
-rw-r--r-- 1 root root 1012 Nov 16 15:20 zzcweb.top.csr
-rw-r--r-- 1 root root 1674 Nov 16 15:20 zzcweb.top.key
-rw-r--r-- 1 root root 3905 Nov 16 15:20 zzcweb.top.pem
-rw-r--r-- 1 root root 23744 Nov 16 15:20 zzcweb.top.zip
[root@jenkins /etc/gitlab/ssl/Nginx]# mv 1_zzcweb.top_bundle.crt ../zzcweb.crt
[root@jenkins /etc/gitlab/ssl/Nginx]# mv 2_zzcweb.top.key ../zzcweb.key
#修改配置文件
[root@jenkins ~]# grep -Ev '^#|^$' /etc/gitlab/gitlab.rb
external_url 'http://www.zzcweb.top'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.126.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "zzc141145@126.com"
gitlab_rails['smtp_password'] = "MZDBMxxxxxxIFDHT"
gitlab_rails['smtp_domain'] = "126.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = 'zzc141145@126.com'
nginx['enable'] = true
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/zzcweb.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/zzcweb.key"
nginx['ssl_protocols'] = "TLSv1.2 TLSv1.3"
nginx['ssl_session_timeout'] = "5m"
nginx['listen_port'] = 443
nginx['listen_https'] = true
#启动服务 注意:除第一次之外,其他刷新配置都不会启动gitlab
[root@jenkins ~]# gitlab-ctl reconfigure
#Gitlab常用命令
gitlab-ctl reconfigure #启动服务 注意:除第一次之外,其他刷新配置都不会启动gitlab
gitlab-ctl status #查看状态
gitlab-ctl start # 启动所有 gitlab 组件
gitlab-ctl stop # 停止所有 gitlab 组件
gitlab-ctl restart # 重启所有 gitlab 组件
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab
gitlab-ctl tail # 查看日志
#本地配置hosts
10.0.0.91 www.zzcweb.top
#浏览器访问:www.zzcweb.top
#打开控制台测试邮件
[root@jenkins ~]# cd /opt/gitlab/bin
[root@jenkins /opt/gitlab/bin]# ll
-rwxr-xr-x 1 root root 3692 Apr 28 2021 gitlab-backup
-rwxr-xr-x 1 root root 1418 Apr 28 2021 gitlab-ctl
-rwxr-xr-x 1 root root 250 Apr 28 2021 gitlab-healthcheck
-rwxr-xr-x 1 root root 702 Apr 28 2021 gitlab-psql
-rwxr-xr-x 1 root root 1301 Apr 28 2021 gitlab-rails
-rwxr-xr-x 1 root root 1300 Apr 28 2021 gitlab-rake
-rwxr-xr-x 1 root root 711 Apr 28 2021 gitlab-redis-cli
-rwxr-xr-x 1 root root 1300 Apr 28 2021 gitlab-ruby
[root@jenkins /opt/gitlab/bin]# gitlab-rails console
--------------------------------------------------------------------------------
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
GitLab: 13.9.7 (05f9b5a73c8) FOSS
GitLab Shell: 13.17.0
PostgreSQL: 12.6
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.4)
irb(main):001:0> Notify.test_email('zzc141145@126.com','hi','hello world').deliver_now
![](https://img2020.cnblogs.com/blog/2106720/202111/2106720-20211116183626353-1829743830.png)