gitlab 7をrehl 6にワンタッチで取り付ける.4上

11676 ワード

gitlab 7をrehl 6にワンタッチで取り付ける.4上
参考原文:
http://blog.csdn.net/ubuntu64fan/article/details/38367579
1 gitlab 7について
いずれにしてもgitlabは良いものですが、インストールと構成は極めて難しいです.bitnami(https://bitnami.com/)のワンタッチインストールパッケージは大きな問題を解決できますがgitlab+nginxやemail送信などの問題を構成できない人が多いです.今日は特に完璧にもう一度整理します.読者の皆さんの質問にはもう一つ一つ答えません.
まず、bitmamiのいくつかのバージョンに問題があり、rhel 6で成功できません.4に正常にインストールされました.そこで、7.8.1(レスポンスページ)の新しいバージョンを見つけました.
ftp://pepstack.com/pub/tarball/bitnami-gitlab-7.8.1-0-linux-x64-installer.run
(私のftpはずっと提供しないので、できるだけ早くダウンロードしてください)
では、最後にインストールした効果は(アクセス可能をクリックすると、最初のアクセスが遅くなる可能性があります.新しいバージョンのfirefoxまたはchromeが要求されます.IEはテストされていません):
http://pepstack.com/gitlab
2需要説明
では、まず需要を述べて、もし読者の需要が私と違っていたら、私は何もできません.もし私が1台のwebホスト(私はpepstack.com)を持っているとしたら、ホストの後ろに仮想マシン(vm-gitlab)を作成し、vm-gitlabにgitlab 7をインストールし、webホスト上のngnixを構成することで、次のurlを通じて私のgitlabにアクセスすることができます.
http://pepstack.com/gitlab
仮想マシンvm-gitlabを作成するプロセスは詳しくは言いませんが、実体マシンを使用する場合も同じです.vm-gitlabはrhel 6をインストールしています.4バージョン.vm内部で外部ホストやインターネット(ping www.baidu.comなど)にアクセスできることを確認します.
3 gitlabのインストール
sshからvm-gitlab:
# ssh root@vm-gitlab
ワンタッチのインストールパッケージをダウンロードします.
# wget ftp://pepstack.com/pub/tarball/bitnami-gitlab-7.8.1-0-linux-x64-installer.run
インストール:
# chmod a+x bitnami-gitlab-7.8.1-0-linux-x64-installer.run# ./bitnami-gitlab-7.8.1-0-linux-x64-installer.runインストール中にプロンプトが表示されます.
----------------------------------------------------------------------------
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.8.1-0]:

----------------------------------------------------------------------------
Create Admin account

Bitnami Gitlab Stack admin user creation

Email Address [[email protected]]: [email protected]

Login [user]: master (      gitlab     )

Password : (     gitlab      )
Please confirm your password :  (     gitlab      )
----------------------------------------------------------------------------
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 [127.0.0.1]:

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 : (    QQ  )
Re-enter : (    QQ  )
SMTP Host []: smtp.qq.com

SMTP Port []: 25

Secure connection

[1] None
[2] SSL
[3] TLS
Please choose an option [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://127.0.0.1:80 from your browser.
Press [Enter] to continue:

4 gitlabの構成
構成は特に注意してください.次のプロファイルを使用します.
/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/config/environments/production.rb
/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/config/initializers/smtp_settings.rb
/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/config/gitlab.yml
/opt/gitlab-7.8.1-0/apps/gitlab/conf/httpd-app.conf
/opt/gitlab-7.8.1-0/apps/gitlab/gitlab-shell/config.yml

以下、一つ一つ説明します.
4.1 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 => "qq.com",
    :authentication => :plain,
    :user_name => "[email protected]",
    :password => "********",
    :enable_starttls_auto => true
  }

  config.eager_load = true
  config.assets.js_compressor = :uglifier

  config.allow_concurrency = false
......

4.2 smtp_settings.rb
# cp smtp_settings.rb.sample smtp_settings.rb
# To enable smtp email delivery for your GitLab instance do the following:
# 1. Rename smtp_settings.rb.sample 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: :login,
    enable_starttls_auto: true,
    openssl_verify_mode: 'none'
  }
end

4.3 gitlab.yml
# # # # # # # # # # # # # # # # # #
# GitLab application config file  #
# # # # # # # # # # # # # # # # # #
#
# How to use:
# 1. Copy file as gitlab.yml
# 2. Update gitlab -> host with your fully qualified domain name
# 3. Update gitlab -> email_from
# 4. If you installed Git from source, change git -> bin_path to /usr/local/bin/git
# 5. Review this configuration file for other settings you may want to adjust

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

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: pepstack.com
    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

    # 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

    ## Date & Time settings
    # Uncomment and customize if you want to change the default time zone of GitLab application.
    # To see all available zones, run `bundle exec rake time:zones:all RAILS_ENV=production`
    # time_zone: 'UTC'

    ## 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: [email protected]
    support_email: [email protected]

    # Email server smtp settings are in config/initializers/smtp_settings.rb.sample

    # default_can_create_group: false  # default: true
    # username_changing_enabled: false # default: true - User can change her username/namespace
    ## Default theme
    ##   BASIC  = 1
    ##   MARS   = 2
    ##   MODERN = 3
    ##   GRAY   = 4
    ##   COLOR  = 5
    # default_theme: 2 # default: 2
...... 

上のファイルの変更点は、次の点です.
host: pepstack.comrelative_url_root:/gitlabemail_from: [email protected]_email: [email protected]
次の構成はgitlabをnginxの後ろに置いて使用するためです.
4.4 httpd-app.conf

    Options -MultiViews
    AllowOverride All
    
        Order allow,deny
        Allow from all
    
    = 2.3>
        Require all granted
    

    SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"

    PassengerEnabled on
    PassengerAppRoot "/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/"
    
        ModPagespeedDisallow "*"
    
    PassengerUser git
    PassengerGroup git
    SetEnv MAGIC "/opt/gitlab-7.8.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.8.1-0/python/bin:${PATH}"



PassengerPreStart http://127.0.0.1:80/gitlab

違いは次の点です.
SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"PassengerPreStart http://127.0.0.1:80/gitlab
4.5 config.yml
...
gitlab_url: http://pepstack.com:80/gitlab/
...

gitlabにアクセスするには、次のアドレスに従います.
http://pepstack.com/gitlab/
5ホストnginx構成
上記の構成はvm-gitlabで行い、80:httpポートを開くことに注意してください.次に、ホストnginxに構成、プロファイルを追加します.
/etc/nginx/conf.d/redmine.conf
内容は以下の通りです(redmineサービスも提供しています):
#     redmine web  (192.168.122.21:80)
#
upstream redmine {
    server 192.168.122.21:80;
}

upstream gitlab {
    server 192.168.122.20:80;
}

server {
    server_name pepstack.com;

    # /var/log/nginx         
    access_log  /var/log/nginx/redmine_access.log;
    error_log   /var/log/nginx/redmine_error.log;

    location /redmine {
        try_files $uri @red;      # @red       
    }

    location /gitlab {
        try_files $uri @git;
    }

    location @red {
        proxy_set_header  Host             $host;
        proxy_set_header  X-Real_IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;

        proxy_read_timeout     300;
        proxy_connect_timeout  300;
        proxy_redirect         off;

        proxy_pass http://redmine;  #    upstream redmine
    }

    location @git {
        proxy_set_header  Host             $host;
        proxy_set_header  X-Real_IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;

        proxy_read_timeout     300;
        proxy_connect_timeout  300;
        proxy_redirect         off;

        proxy_pass http://gitlab;  #    upstream gitlab
    }
}

注意:
/etc/nginx/nginx.conf
......
http {
......
        include /etc/nginx/conf.d/*.conf;
        #  include /etc/nginx/sites-enabled/*;
}
......

注記:include/etc/nginx/sites-enabled/*
6サービスの開始
大きな成果を上げ、ホストでnginxを起動します.
$ sudo nginx -s reload
vm-gitlabでgitlabを起動します.
# cd/opt/gitlab-7.8.1-0/
# ./ctlscript.sh restart