说明:第一次配置好,其他可以用,邮件发送不了,各种找问题,终于解决(本人实在内网服务器使用BitnamiGitlab搭建的)
CentOS 6.5搭建Gitlab步骤:
1、bitnami-gitlab-8.2.3-4-linux-x64-installer.run下载地址(可能已停止对外下载,点击下载)
https://bitnami.com/stack/gitlab/installer
2、安装
执行命令:./bitnami-gitlab-8.2.3-4-linux-x64-installer.run按照提示一路进行(可能需要授权:chmod a+x bitnami-gitlab-8.2.3-4-linux-x64-installer.run)
注意:安装过程这有几个注意点
(1)Domain [127.0.0.1]:一定要改成真实的IP,否则邮件发送里的连接是127.0.0.1,别人是打不开的
(2)安装邮件发送
Do you want to configure mail support? [y/N]: y
Configure SMTP Settings This is required so your application can send notifications via email. Default email provider: [1] GMail [2] Custom
Please choose an option [1] : 2
Configure SMTP Settings This data is stored in the application configuration files and may be visible to others. For this reason, it is recommended
that you do not use your personal account credentials.
Username []: xxxxx@heyejr.com (我用的是腾讯的企业邮箱)
Password : xxx
Re-enter : xxx
SMTP Host []: smtp.exmail.qq.com
SMTP Port []: 25
Secure connection [1] None [2] SSL [3] TLS
Please choose an option [3] :3
(3)接下来确认,等一会进度条走完就安装完成了
3、重要!此时还不能发送邮件。需要更改几个配置
(1)进入目录,执行命令
cd gitlab-8.2.3-4/apps/gitlab/htdocs/config/environments
vim production.rb
修改内容如下:
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.exmail.qq.com",
:port => "25",
:domain => "exmail.qq.com",
:authentication => :plain,
:user_name => "xxx@heyejr.com",
:password => "xxx",
:enable_starttls_auto => true
}
注意:这里要跟前面的配置一致
(2)cd gitlab-8.2.3-4/apps/gitlab/htdocs/config/initializers
cp smtp_settings.rb.sample smtp_settings.rb
vim smtp_settings.rb
修改内容如下:
if Rails.env.production?
Gitlab::Application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: "smtp.exmail.qq.com",
port: 25,
user_name: "xxx@heyejr.com",
password: "xxx",
domain: "exmail.qq.com",
authentication: :login,
enable_starttls_auto: true
}
(3)cd gitlab-8.2.3-4/apps/gitlab/htdocs/config
vim gitlab.yml
修改内容如下:
production: &base
#
# 1. GitLab app settings
# ==========================
## GitLab settings
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 192.168.4.220(你自己的IP)
port: 80 # Set to 443 if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
https: false # Set to true if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
## Email settings
# Uncomment and set to false if you need to disable email sending from GitLab (default: true)
# email_enabled: true
# Email address used in the "From" field in mails sent by GitLab
email_from: xxx@heyejr.com
email_display_name: GitLab
email_reply_to: xxx@heyejr.com
# Email server smtp settings are in config/initializers/smtp_settings.rb.sample
4、重启Gitlab服务
cd gitlab-8.2.3-4
./ctlscript.sh restart
等待启动完成,此时创建用户,就会发送邮件了。
到此配置全部完成,谢谢!