Linux-Gitlabのインストール


time 20191203
author Venki
ディレクトリガイド
  • gitlab取付
  • gitlab漢化
  • gitlabサーバ交換
  • 補助資料
  • gitlabインストール
  • 準備説明
  • CPUコア2個以上
  • 実行メモリ4 G(公式には2 G以上と言われていますが、カートンはよく出てきますが、gitlabを1台のサーバで専用に配置することは一般的に不可能で、他のサービスが同時に並行しているので、4 G以上が望ましいでしょう)
  • 私の操作心理状態はcentOs 7です.7
  • 取り付け開始
  • yumソース
  • の構成
    vim /etc/yum.repos.d/gitlab-ce.repo
    
    #          
    [gitlab-ce]
    name=Gitlab CE Repository
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
    gpgcheck=0
    enabled=1
    
  • ローカルyumキャッシュ
  • を更新
    yum makecache
    
  • インストールGitLabコミュニティ版
  • #        
    yum install gitlab-ce
    
    #       
    yum install gitlab-ce-x.x.x
    
  • 初期化gitlab
  • #           ,  4-5min
    gitlab-ctl reconfigure
    
  • アクセス
  • サーバーに他のwebサーバーが配置されていない場合は、直接サーバーのIPアドレスを入力してアクセスできますが、私のサーバーにはすでにNginxが配置されているので、私はまずNginxを停止してからアクセスを行い、テストに成功しました.次に、gitlabのデフォルトのサーバーを私の構成のサーバーに変更する方法をします.
    gitlab漢化はトップに戻る
    しばらくは漢化しないで、英語版のほうがいいです.結局、プログラマーで、元の生態を使っています.
    gitlabサーバをトップに戻す
  • サービスをイントラネット
  • に配備する
    #    Windowshosts          cms(code management system)
    192.168.1.243 gd.cms.com
    
    #            
    
  • を独自のNginxサーバ
  • に交換
  • gitlabが所有するNginxサーバ
  • を無効にする
    vi /etc/gitlab/gitlab.rb
    
    #  nginx['enable'] = false      ,   1072 
    
  • ドメイン名をカスタムドメイン名に変更
  • vi /etc/gitlab/gitlab.rb
    
    #   external_url 'http://gd.cms.com'  
    
  • gitlabの新しいNginxプロファイル
  • # gitlab   Nginx    
    cd /var/opt/gitlab/nginx/conf
    
    # gitlab-http.conf         
    
    #         /usr/local/nginx/conf/vhost/           ,      ,    copy       
    upstream gitlab {
      #             
      server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
    }
    
    server {
      server_name gd.cms.com;   #         
    
      server_tokens off;     # don't show the version number, a security best practice
      root /opt/gitlab/embedded/service/gitlab-rails/public;
    
      # Increase this if you want to upload large attachments
      # Or if you want to accept large git objects over http
      client_max_body_size 250m;
    
      # individual nginx logs for this gitlab vhost
      access_log  /var/log/gitlab/nginx/gitlab_access.log;
      error_log   /var/log/gitlab/nginx/gitlab_error.log;
    
      location / {
        # serve static files from defined root folder;.
        # @gitlab is a named location for the upstream fallback, see below
        try_files $uri $uri/index.html $uri.html @gitlab;
      }
    
      # if a file, which is not found in the root folder is requested,
      # then the proxy pass the request to the upsteam (gitlab unicorn)
      location @gitlab {
        # If you use https make sure you disable gzip compression 
        # to be safe against BREACH attack
    
        proxy_read_timeout 300; # Some requests take more than 30 seconds.
        proxy_connect_timeout 300; # Some requests take more than 30 seconds.
        proxy_redirect     off;
    
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header   X-Frame-Options   SAMEORIGIN;
    
        proxy_pass http://gitlab;
      }
    
      # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
      # WARNING: If you are using relative urls do remove the block below
      # See config/application.rb under "Relative url support" for the list of
      # other files that need to be changed for relative url support
      location ~ ^/(assets)/  {
        root /opt/gitlab/embedded/service/gitlab-rails/public;
        # gzip_static on; # to serve pre-gzipped version
        expires max;
        add_header Cache-Control public;
      }
    
      error_page 502 /502.html;
    }
    
    #   Nginx      
    /usr/local/nginx/sbin/nginx -t
    
    #   gitlab   Nginx  
    gitlab-ctl reconfigure
    
    service nginx restart
    
  • 説明
  • 元のgitlabが持っていたNginxサービスを停止したため、gitlabを初期化するとアクセスできなくなり、Nginxプロセスを表示し、起動しなかった場合は、この時点でNginxを起動すればよい!ドメイン名にアクセスするとすぐにアクセスできます!
    gitlab構成は上部に戻る
  • windows下git接続gitlab
  • windowsの下にssh(sshによる秘密保護接続)
  • を配置する.
    # git-bash  ,  C:\Users\MyPC\.ssh     ,      gitlab   
    ssh-keygen -t rsa -C "[email protected]"
    

    自分のssh公開鍵をgitlabにアップロードすればgit cloneのたびにコードをフリーにすることができますが、クローンアドレスはsshに対応しています.また、すべての権限倉庫のコードを引き出すことができます.
  • Windowsの下でアカウントのパスワードを通じて接続します–しばらく
  • をやり遂げていません
    #   git        
    git config --system --unset credential.helper
    
    #       (global)  
    git config --global  --list
    
    #           
    git config --local  --list
    
  • Linuxの下にgit接続ssh(主にwalle自動化配置用)
  • を構成する
  • ユーザグループおよびユーザ構成

  • git構成
  • git初期化user.nameとuser.Emailエラー、交換したい場合はコマンドを再入力
  • git config --global user.name '   '
    git config --global user.email '[email protected]'
    

    補助資料を上部に戻す
  • 参考文献
  • GitLabのインストールおよび使用チュートリアル
  • gitlabデフォルトNginx
  • を変更
  • Gitlab管理ユーザ、グループ、権限(一)
  • gitlab使用詳細
  • 参照コマンド
  • #         
    cat /etc/issue
    #  
    cat /etc/centos-release
    
    #      gitlab   
    gitlab-ctl start    
    
    #      gitlab   
    sudo gitlab-ctl stop 
    
    #      gitlab   
    sudo gitlab-ctl restart       
    
    #       
    sudo gitlab-ctl status        
    
    #     
    sudo gitlab-ctl reconfigure        
    
    #          
    sudo vim /etc/gitlab/gitlab.rb        
    
    #   gitlab
    gitlab-rake gitlab:check SANITIZE=true --trace   
    
    #     
    sudo gitlab-ctl tail        
    
    #   git   
    git config -l
    
  • 問題
  • connect() to unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed (13: Permission denied) while connecting toupstream,client:192.168.1.242, server: gl.cms.com, request:“GET/favicon.icoHTTP/1.1”,upstream:“http://unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket:/favicon.ico”,host:“cms.gl.com”, referrer: “http://cms.gl.com/”

  • 問題の原因は私が読むことです.
  • nginxはgitlabのsocket権限
  • にアクセスしていません.
    解決策
  • nginxを実行しているユーザーを表示します.私のはwww
  • です.
    ps -ef | grep nginx
    root      21556      1  0 17:23 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
    www       21557  21556  0 17:23 ?        00:00:00 nginx: worker process
    root      21881   9830  0 17:26 pts/2    00:00:00 grep --color=auto nginx
    
  • wwwユーザをgitlab-wwwグループ
  • に加入する
    #   sockets             
    ll /var/opt/gitlab/gitlab-rails/
    
    usermod -a -G gitlab-www www
    
  • 変更構成
  • vim /etc/gitlab/gitlab.rb
    web_server['external_users'] = ['www']
    
  • gitlab
  • を再起動
    gitlab-ctl reconfigure
    
  • nginx
  • を再起動
    service nginx restart