一键安装 gitlab7 on rhel6.4 并设置邮件发送

一键安装 gitlab7 on rhel6.4 并设置邮件发送

世间本无事,庸人自扰之。书归正传,简短节说:gitlab是个好东西,可是安装手冊奇烂。尽管以前对比文档一步一步安装起来gitlab 6.x,可是,时过境迁,再也不想把时间花在这无聊的配置上。谷歌已然变成往日黄花,又无翻越墙狱之利器,仅仅能在百度和Bing之间来回寻找答案。功夫不负苦心人。最终找到这个bitnami的一键安装包。

bitnami-gitlab-7.1.1-0-linux-x64-installer.run。

https://bitnami.com/redirect/to/39039/bitnami-gitlab-7.1.1-0-linux-x64-installer.run

1 安装gitlab全过程

下载还是出奇的慢。以下是安装全过程:

[[email protected] ~]# service mysqld stop
Stopping mysqld:                                           [  OK  ]
[[email protected] ~]# ./bitnami-gitlab-7.1.1-0-linux-x64-installer.run
The installer detects that exists a ‘git‘ user in the system. This installer will change the config                        uration for this user. Do you want to continue the installation? [y/N]: y

The installer detects that exists a ‘gitlab_ci‘ user in the system. This installer will change the                         configuration for this user. Do you want to continue the installation? [y/N]: y

----------------------------------------------------------------------------
Welcome to the Bitnami Gitlab Stack Setup Wizard.

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.
GitLab : Y (Cannot be edited)
GitLab CI [Y/n] :Y

Is the selection above correct? [Y/n]: Y

----------------------------------------------------------------------------
Installation folder
Please, choose a folder to install Bitnami Gitlab Stack
Select a folder [/opt/gitlab-7.1.1-0]:

----------------------------------------------------------------------------
Create Admin account
Bitnami Gitlab Stack admin user creation
Email Address [[email protected]]: [email protected]
Login [user]: master
Password :88888888
Please confirm your password :88888888
----------------------------------------------------------------------------
Hostname that will be used to create internal URLs. If this value is incorrect,
you may be unable to access your Gitlab installation from other computers. It is
advisable to use a Domain instead of an IP address for compatibility with
different browsers.

Domain [192.168.82.181]:
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 []: [email protected]

Password :
Re-enter :
SMTP Host []: smtp.qq.com

SMTP Port []: 25

Secure connection

[1] None
[2] SSL
[3] TLS
Please choose an option [3] :3

----------------------------------------------------------------------------
Setup is now ready to begin installing Bitnami Gitlab Stack on your computer.
Do you want to continue? [Y/n]: y
----------------------------------------------------------------------------
Please wait while Setup installs Bitnami Gitlab Stack on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing Bitnami Gitlab Stack on your computer.

Info: To access the Bitnami Gitlab Stack, go to
http://192.168.82.181:80 from your browser.
Press [Enter] to continue:

2 更改配置以发送邮件

重要!此时还不能发送邮件。须要更改几个配置:

1)config/environments/production.rb

# vi /opt/gitlab-7.1.1-0/apps/gitlab/htdocs/config/environments/production.rb
  ........
  # config.action_mailer.delivery_method = :sendmail
  # Defaults to:
  # # config.action_mailer.sendmail_settings = {
  # #   location: ‘/usr/sbin/sendmail‘,
  # #   arguments: ‘-i -t‘
  # # }
  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.qq.com",
    :port => "25",
    :domain => "smtp.qq.com",
    :authentication => :plain,
    :user_name => "[email protected]",
    :password => "********",
    :enable_starttls_auto => true
  }
  ........

假设发邮件不须要登录和密码,设置为:

    :address => "your smtp server ip",
    :port => "25",
    :domain => "www.mymibao.com",  # 域名无所谓
    :authentication => :none,      # 无需登录
    # 以下凝视掉
    #:user_name => "[email protected]",
    #:password => "********",
    #:enable_starttls_auto => true

2)smtp_settings.rb

  # cd /opt/gitlab-7.1.1-0/apps/gitlab/htdocs/config/initializers/
  # cp smtp_settings.rb.sample smtp_settings.rb
  # vi smtp_settings.rb

内容截取例如以下:

# To enable smtp email delivery for your GitLab instance do next:
# 1. Rename this file to smtp_settings.rb
# 2. Edit settings inside this file
# 3. Restart GitLab instance
#
if Rails.env.production?
  Gitlab::Application.config.action_mailer.delivery_method = :smtp

  ActionMailer::Base.smtp_settings = {
    address: "smtp.qq.com",
    port: 25,
    user_name: "[email protected]",
    password: "********",
    domain: "qq.com",
    #authentication: :none
    #enable_startttls_auto: true
    authentication: :login,
    enable_starttls_auto: true
  }
end

3)config/gitlab.yml

找到以下的内容,改成你的email地址:

# # # # # # # # # # # # # # # # # #
# GitLab application config file  #
# # # # # # # # # # # # # # # # # #
#
# How to use:
# 1. copy file as gitlab.yml
# 2. Replace gitlab -> host with your domain
# 3. Replace gitlab -> email_from

production: &base
  #
  # 1. GitLab app settings
  # ==========================

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: 192.168.82.181
    port: 80
    https: false

    # Uncommment this line below if your ssh host is different from HTTP/HTTPS one
    # (you‘d obviously need to replace ssh.host_example.com with your own host).
    # Otherwise, ssh host will be set to the `host:` value above
    # ssh_host: ssh.host_example.com

    # WARNING: See config/application.rb under "Relative url support" for the list of
    # other files that need to be changed for relative url support
    # relative_url_root: /gitlab

    # Uncomment and customize if you can‘t use the default user to run GitLab (default: ‘git‘)
    # user: git

    ## Email settings
    # Email address used in the "From" field in mails sent by GitLab
    email_from: [email protected]
    support_email: [email protected]

    # Email server smtp settings are in [a separate file](initializers/smtp_settings.rb.sample).
........


注意,假设你依照上面的设置,出如今用户的邮件以下的地址链接将是:

http://192.168.82.181:80/...

通常这个链接是内部的地址,用户点击是无效的。因此我须要修改上面的配置文件,使邮件地址链接指向有意义。比如,我须要用以下的地址进入gitlab。(www.mymibao.com是我假设的名字)

http://www.mymibao.com/gitlab

我的config/gitlab.yml修改例如以下:

host: www.mymibao.com

relative_url_root: /gitlab

这样,出如今用户邮件里的链接地址为:

http://www.mymibao.com.gitlab/...

3 启动服务并訪问

# /opt/gitlab-7.1.1-0/ctlscript.sh restart

此时创建用户,就会发送邮件了。

别忘记 qq邮箱中打开以下的服务:

以上在RHEL6.4上经过严格測试。

4 将gitlab置于nginx后面

上面的设置无法正常工作于nginx后面。假设想用另外服务器上的nginx指向这台gitlab,就须要更改gitlab的几处配置文件:

1) /opt/gitlab-7.1.1-0/apps/gitlab/conf/httpd-app.conf

更改之后例如以下:

<Directory "/opt/gitlab-7.1.1-0/apps/gitlab/htdocs/public">
    PassengerEnabled on
    Options -MultiViews
    AllowOverride All
    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>

    SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
    PassengerAppRoot "/opt/gitlab-7.1.1-0/apps/gitlab/htdocs"
    <IfModule pagespeed_module>
        ModPagespeedDisallow "*"
    </IfModule>
    PassengerUser git
    PassengerGroup git
    SetEnv MAGIC "/opt/gitlab-7.1.1-0/ruby/lib/ruby/gems/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/magic/magic.mgc"
    SetEnv PATH "/opt/gitlab-7.1.1-0/python/bin:${PATH}"

</Directory>

PassengerPreStart http://127.0.0.1:80/gitlab

更改前的例如以下,注意它们的差别:

<Directory "/opt/gitlab-7.1.1-0/apps/gitlab/htdocs/public">
    PassengerEnabled on
    Options -MultiViews
    AllowOverride All
    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>

    PassengerAppRoot "/opt/gitlab-7.1.1-0/apps/gitlab/htdocs"
    <IfModule pagespeed_module>
        ModPagespeedDisallow "*"
    </IfModule>
    PassengerUser git
    PassengerGroup git
    SetEnv MAGIC "/opt/gitlab-7.1.1-0/ruby/lib/ruby/gems/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/magic/magic.mgc"
    SetEnv PATH "/opt/gitlab-7.1.1-0/python/bin:${PATH}"

</Directory>

PassengerPreStart http://127.0.0.1:80

2) /opt/gitlab-7.1.1-0/apps/gitlab/gitlab-shell/config.yml

找到以下的一句:

# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://vm-gitlab.com:80/"

更改例如以下:

# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://vm-gitlab.com:80/gitlab/"

这样我们訪问gitlab就是依照以下的地址:

http://vm-gitlab.com:80/gitlab/

假设不修改这里,每次git push的时候将出现以下的错误:

cl@ubuntu64:~/workspace/vm-gitlab7/test2$ git add .
cl@ubuntu64:~/workspace/vm-gitlab7/test2$ git commit -m ‘first commit‘
[master (root-commit) f0779c8] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 test2/README
cl@ubuntu64:~/workspace/vm-gitlab7/test2$ git remote add origin http://vm-gitlab.com/gitlab/master/test2.git
cl@ubuntu64:~/workspace/vm-gitlab7/test2$ git push -u origin master
Username for ‘http://vm-gitlab.com‘: master
Password for ‘http://master@vm-gitlab.com‘:
Counting objects: 4, done.
Writing objects: 100% (4/4), 250 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: GitLab: You are not allowed to access master!
remote: error: hook declined to update refs/heads/master
To http://vm-gitlab.com/gitlab/master/test2.git
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to ‘http://vm-gitlab.com/gitlab/master/test2.git‘

配置修改之后,又一次启动gitlab,一切正常。

/opt/gitlab-7.1.1-0/ctlscript.sh restart

时间: 2024-11-04 19:06:25

一键安装 gitlab7 on rhel6.4 并设置邮件发送的相关文章

zabbix -- 一键安装2.4.7客户端 (附:邮件、微信警报)

小Q:各位,最近一直在玩zabbix,写点总结. 1.搭建安装脚本,一键安装2.4.7 客户端 2.报警脚本(微信 邮件) ---------------------------------------------------------------------------------------------- 1.搭建安装脚本,一键安装2.4.7 客户端 a.首先要找一台原始服务器,放置zabbix_2.4.7安装包,和一个已经写好适合自己的配置文件. b.脚本如下 #!/bin/bash f

linux环境下设置邮件发送

日常工作中对主机巡检,备份,查看性能 等等,设置指定邮件账户,在指定动作操作完后,由该账户发送到指定收件人中,这样能帮助我们能及时了解主机状态,防患未然. /etc/mail.rc 是mailx 用户代理缺省设置 举例1: 编辑 /etc/mail.rc文件 添加要使用stmp地址,账户,密码 set [email protected]                      邮件账户 set smtp=smtp.163.com                                

zabbix设置邮件发送报警

找到QQ邮件服务器地址 打开QQ邮箱-设置-账户 开启POP3/SMTP服务 生成授权码,记住这个授权码 找到QQ的SMTP服务器地址 配置发件人Email信息 管理-报警媒介类型-Email 填写相关信息如下 配置收件人Email信息 选择用户-Admin 选择报警媒介-添加 启用报警 配置-动作-Report problems to Zabbix administrators 配置相关报警信息 启用报警 自定义报警信息 发送警告 默认标题: 故障{TRIGGER.STATUS},服务器:{H

lanmp的一键安装脚本

创建lanmp一键安装的脚本 思路:1.设置自动安装lamp和lnmp 2.lamp脚本的编译安装 (mysql版本 5.1 或者5.6 二个版本) (apache 版本 2.2版本) (php 版本 5.4版本 5.6版本) 3.lnmp脚本的编译安装 (mysql版本 5.1 或者5.6 二个版本) (nginx 版本 1.6版本) (php 版本 5.4版本 5.6版本) 修改权限 chmod a+x lanmp.sh vim lanmp.sh #设置lamp 或 lnmp的脚本安装 #!

图文详解zabbix的安装以及设置邮件报警

简介:1.zabbix的介绍 2.zabbix的服务端安装 3.浏览器安装zabbix 4.zabbix的客户端安装 5.添加一个客户端 6.设置邮件报警 zabbix的介绍 zabbix(音同 zbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题. zabbix由2部分构成,zabbix server与可选组件zabbix agent.

zabbix3.0.4设置邮件告警

一.安装sendEmail [[email protected] ~]# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz [[email protected] ~]# mkdir /usr/local/bin [[email protected] ~]# tar zxvf sendEmail-v1.56.tar.gz [[email protected] ~]# cd sendEmail

PXE一键安装脚本

PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包

一键安装ftp服务器

1 概述 工作中,需要搭建ftp服务器来实现资源的共享.本文将通过脚本实现自动化安装ftp服务器,并进行相关配置,同时创建ftp登录账户,以及创建两个文件夹,作为公共的文件夹,为所有用户提供共同的访问路径. 2 概念解释和注意事项 2.1 chroot_list说明 chroot_list_file=/etc/vsftpd/chroot_list 如果设置为 chroot_local_user=YES chroot_list_enable=YES(这行可以没有, 也可以有) chroot_lis

在空白主机上一键安装kickstart服务,分发centos5.8和mysql5.7.16

#!/bin/bash chkconfig --add sshd  chkconfig sshd on yum -y install vim man wget #需关闭虚拟交换机的DHCP功能 #需要开放网络 #本机网段192.168.2.x IP20 #客户机硬盘大小100GB #借用了同班同学的Mysql一键安装版本 #安装完成后客户机手动确认重启         line194可修改为自动重启 #缺少判断mysql是否成功下载并提示的判断: # 1.本地FTP共享文件夹是否有mysql*.