centos7安装gitlab 支持带认证https,开启邮件功能 超级简单.

官方安装说明:https://about.gitlab.com/install/#centos-7
自定义yum源 自行搞定
下载gitlab
官方安装:
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
清华大学源下载:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm
yum install gitlab-ce-11.10.4-ce.0.el7.x86_64.rpm -y
关防火墙 和 selinux
vim /etc/selinux/config
修改配置文件
vim /etc/gitlab/gitlab.rb

设置 https支持 [这里要注意,必须设置为https://你的域名,不然后面设置证书什么都不会生效的] <----- 有坑的.请注意

##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'https://gitlab.你的域名.com'

设置证书

再也不用忽略证书问题了,因为证书没问题了.
证书可以从 letsencrypt 生成免费的证书..(默认浏览器和工具都不会提示不安全警告的.)
详情参考:https://github.com/Neilpang/acme.sh/wiki/%E8%AF%B4%E6%98%8E

##! Most root CA's are included by default
nginx['ssl_client_certificate'] = "/home/centos/sslkeys/ca.crt"

##! enable/disable 2-way SSL client authentication
# nginx['ssl_verify_client'] = "off"

##! if ssl_verify_client on, verification depth in the client certificates chain
# nginx['ssl_verify_depth'] = "1"

nginx['ssl_certificate'] = "/home/centos/sslkeys/fullchain.cer"
nginx['ssl_certificate_key'] = "/home/centos/sslkeys/gitlab.你的域名.com.key"

设置Email支持

### GitLab email server settings
###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html
###! **Use smtp instead of sendmail/postfix.**
#这里使用的是阿里云推送 每日免费200封.
#  详细开通 这里哦 --->  https://dm.console.aliyun.com/?spm=5176.12818093.my.ddm.488716d0ezCKP2#/directmail/Home/cn-hangzhou

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtpdm.aliyun.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "admin@mail.你填写的域名.com"  
gitlab_rails['smtp_password'] = "密码"
gitlab_rails['smtp_domain'] = "smtpdm.aliyun.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

### Email Settings
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'admin@mail.你的域名.com'  #注意要和你的用户名地址要匹配的
gitlab_rails['gitlab_email_display_name'] = 'Gitlab'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@mail.wutoon.com'
gitlab_rails['gitlab_email_subject_suffix'] = ''



阿里云邮件推送 需要设置的项目

先添加域名,不明白看他们的文档, 配置好后要按照要求修改dns解析项目

配置完成执行
gitlab-ctl reconfigure
然后浏览器登录你的 gitlab 第一次它会要求你创建一个管理员密码.
配置觉得有问题可以 vim /etc/gitlab/gitlab.rb 保存之后 在执行 gitlab-ctl reconfigure 重新配置完成即可.

测试email 命令. []
进入控制台gitlab-rails console (测试邮件服务是否正常)
Notify.test_email("XXX@XXX.XX","title","content").deliver_now

测试完成,可以尝试点击忘记密码

posted @ 2019-05-20 20:25  lvusyy  阅读(890)  评论(0编辑  收藏  举报