centos6.3配置gitlab-7.10.0-omnibus(使用smtp服务进行邮件发出)
一、安装部署(目前官网最新版本为8.1.4)
1.依赖包安装
yum install openssh-server cronie -y
#yum install postfix //使用sendmail进行发送邮件需要安装,但是没有配置成功,这里采取smtp服务器进行邮件发出,故不再安装postfix。
#service postfix start
#chkconfig postfix on
lokkit -s http -s ssh
2.下载安装包
curl -O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-ce-7.10.1~omnibus.2-1.x86_64.rpm
3.安装
rpm -i gitlab-ce-7.10.1~omnibus.2-1.x86_64.rpm
==============================
有可能会包rpm(lib*)的错误。请升级rpm软件 yum install rpm -y
==============================
4.配置gitlab e-mail功能
===========================================================
external_url 'http://117.78.7.X'
############################
# gitlab.yml configuration #(/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml)
############################
#E-mail config Date:2015-05-04 Author:qingbo.song
gitlab_rails['time_zone'] = 'UTC'
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_display_name'] = 'APICloud_Gitlab'
gitlab_rails['gitlab_email_reply_to'] = '[email protected]'
#/opt/gitlab/embedded/service/gitlab-rails/config/environments/production.rb#
################################
# GitLab email server settings #
################################
#use smtp to E-mail you Date:2015-05-04 Author:qingbo.song
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "nxgfvizafijytymx"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
#/opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb#
#################################
# application.yml configuration #
#################################
#Date:2015-05-04 Author:qingbo.song
gitlab_ci['smtp_enable'] = true
gitlab_ci['smtp_address'] = "smtp.163.com"
gitlab_ci['smtp_port'] = 25
gitlab_ci['smtp_user_name'] = "[email protected]"
gitlab_ci['smtp_password'] = "nxgfvizafijytymx"
gitlab_ci['smtp_domain'] = "163.com"
gitlab_ci['smtp_authentication'] = "login"
gitlab_ci['smtp_enable_starttls_auto'] = true
=============================================================
5.重置配置,使修改生效
gitlab-ctl reconfigure
6.登录、测试
打开浏览器,输入 'http://117.78.7.X'
Username: root (管理员账号)
Password: 5iveL!fe
使用其他邮箱进行注册测试,看看能不能收到邮件。
gitlab_rails['gravatar_plain_url'] = 'http://117.78.7.X/avatar/%{hash}?s=%{size}&d=identicon'
解决用户头像不能正常显示的问题。
二、开机启动设置
开机自启动脚本设置:
vim /opt/startGitlab.sh
==========================
#! /bin/bash
sudo lokkit -s http -s ssh
==========================
echo "/opt/startGitlab.sh" >> vim /etc/rc.d/rc.local
================================================
三、数据备份与恢复
数据备份及恢复命令:备份path:/var/opt/gitlab/backups (备份和恢复文件都是git用户)
数据备份:gitlab-rake gitlab:backup:backup
数据恢复:gitlab-rake gitlab:backup:restore
================================================
四、gitlab.rb配置
2015.11.20更新:开启自建gitlab平台导入github平台项目功能 (gitlab与github实现认证功能)
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_providers'] = [
{
"name" => "github",
"app_id" => "048eb8c1fbd9c5fa8d4a",
"app_secret" => "49e950c095d0d98758316db1d15f109657fb8532",
"url" => "https://github.com/",
"args" => { "scope" => "user:email" }
}
]
操作步骤:1.现在github.com官网创建一个公共的github管理账号,之后进入账户设置,然后根据下面图示进行操作:
2.实现原理分析:利用第三方(github.com第三方账户)认证证书与个人账户进行认证。涉及到一些不安全的问题,此处不做深入追究。从官方教程来看,是个人账户之间进行认证,为了个人账户安全,这里采用的是第三方账户,官方文档参考:https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/integration/github.md
==========================================================================
升级教程:http://jingyan.baidu.com/article/72ee561ab1b333e16038df63.html
历史版本下载:https://packages.gitlab.com/gitlab/gitlab-ce
Linux下可以直接用mail命令发送邮件,但是发件人是user@servername,如果机器没有外网的dns,其他人就无法回复。此时,有一个可以使用网络免费邮箱服务的邮件发送程序就比较重要了。msmtp就是这样的一个程序。
#1、下载源码包
wget http://sourceforge.net/projects/msmtp/files/msmtp/1.4.32/msmtp-1.4.32.tar.bz2
#2、解压
tar -jxvf msmtp-1.4.32.tar.bz2 && cd msmtp-1.4.32
#build and install
./configure --prefix=/usr/local/msmtp && make && make install
#link to /usr/bin
ln -s /usr/local/msmtp/bin/msmtp /usr/bin/msmtp
#3、新建msmtp的配置文件
mkdir /usr/local/msmtp/etc && vim /usr/local/msmtp/etc/msmtprc
#4、输入如下内容
# Set default values for all following accounts.
defaults
logfile /var/log/msmtp/msmtp.log
# The SMTP server of the provider.
account 163
# SMTP邮件服务器地址
host smtp.163.com
# 发送的邮件Email
from [email protected]
auth login
# 邮件服务器登录账号
user [email protected]
tls off
# 邮件服务器登陆密码
password nxgfvizafijytymx
# Set a default account
account default : 163
#############################################
报错:550 user is lock -->需要添加 tls off
authentication failed (method LOGIN)
将password修改为163服务器开启smtp服务时生成的客户端独立授权密钥
#############################################
#5、测试msmtp是否配置正确
msmtp [email protected]
[ctrl+d]
#6、安装配置mutt
yum install -y mutt
#vim /etc/Muttrc
#输入如下内容:
set sendmail='/usr/local/msmtp/bin/msmtp'
set use_from=yes
set realname='APICloud_Gitlab'
set envelope_from=yes
auto_view text/html
set charset='utf-8'
set send_charset='utf-8'
set locale ='zh_CN.UTF-8'
set content_type = 'text/html\;charset=utf-8'
set rfc2047_parameters=yes
#vim /etc/Muttrc.local
# Local configuration for Mutt.
set sendmail="/usr/local/msmtp/bin/msmtp"
set use_from=yes
set realname="[email protected]"
set editor="vim"
#6、配置完毕,测试一下吧!
echo "Test"|mutt -s "test" [email protected]
收到测试邮件即为成功!
本文出自 “守望海豚” 博客,谢绝转载!