• 云途科技成立于2010年 - 专注全球跨境电商服务器租赁托管!
  • 帮助中心

    您可以通过下方搜索框快速查找您想知道的问题

    ubuntu gitlab nginx 安装配置

      in  unix      Tags: 

    首先申明一点,Ubuntu做为服务器,个人是不推荐的。但是Ubuntu源的东西还是挺全的,要装什么东西都比较方便。

    1,安装gitlab要用的一些组件

    # apt-get install Nginx curl openssh-server ca-certificates postfix
    

    2,安装gitlab

    # curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
    # apt-get install gitlab-ce

    3,配置,启动gitlab

    # cat /etc/gitlab/gitlab.rb | awk '{gsub(/^ +#/,"#",$0);if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}'
    external_url 'http://gitlab.XXXXX.com'  //域名
    git_data_dirs({
     "default" => {
     "path" => "/home/gitlab"   //定义仓库路径
     }
    })
    web_server['external_users'] = ['www-data','gitlab-www','git']    //允许启动gitlab的用户
    Nginx['enable'] = false  //不使用内置Nginx
    
    # gitlab-ctl reconfigure  //配置生效,并启动
    # gitlab-ctl status  //查看状态,或用ps,netstat查看进程
    run: gitaly: (pid 21519) 66501s; run: log: (pid 14077) 70678s
    run: gitlab-monitor: (pid 21531) 66501s; run: log: (pid 14277) 70666s
    run: gitlab-workhorse: (pid 21543) 66500s; run: log: (pid 14015) 70692s
    run: logrotate: (pid 14722) 1699s; run: log: (pid 14044) 70684s
    run: node-exporter: (pid 21561) 66499s; run: log: (pid 14175) 70672s
    run: postgres-exporter: (pid 21566) 66499s; run: log: (pid 14372) 70652s
    run: postgresql: (pid 21576) 66499s; run: log: (pid 13758) 70745s
    run: prometheus: (pid 21658) 66498s; run: log: (pid 14319) 70658s
    run: redis: (pid 21669) 66498s; run: log: (pid 13695) 70751s
    run: redis-exporter: (pid 21673) 66497s; run: log: (pid 14301) 70660s
    run: sidekiq: (pid 24538) 56197s; run: log: (pid 13996) 70698s
    run: unicorn: (pid 21704) 66494s; run: log: (pid 13953) 70704s

    web_server['external_users'] = ['www-data','gitlab-www','git'],这一步很重要,如果不加用户,访问网址的时候,就会报502,

    connect() to unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed (13: Permission denied) while connecting to upstream

    查看一下Nginx.conf就可以知道,nginx的启动用户,加到web_server就行了

    4,配置nginx

    # cat /etc/nginx/sites-enabled/gitlab.conf
    upstream gitlab {
    # 7.x 版本在此位置
    # server unix:/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket;
    # 8.0 位置
     server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
    }
    
    server {
     listen 80;
     server_name gitlab.XXXXX.com;
     root /opt/gitlab/embedded/service/gitlab-rails/public;
    
     # individual nginx logs for this gitlab vhost
     access_log /var/log/Nginx/gitlab_access.log;
     error_log /var/log/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 {
     proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
     proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
     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_pass http://gitlab;
     }
    }
    
    # /etc/init.d/Nginx start

    然后就可以访问http://gitlab.XXXXX.com,就ok了



    • 外贸虚拟主机

      1GB硬盘

      2个独立站点

      1000M带宽

      不限制流量

      美国外贸专用虚拟主机,cPanel面板,每天远程备份.
      服务器配置:2*E5 32核,96GB 内存,4*2TB 硬盘 RAID10 阵列.

      ¥180/年

    • 美国/荷兰外贸VPS

      2核CPU

      1G内存

      30硬盘

      10M带宽

      美国/荷兰外贸云服务器,专注外贸服务器行业12年.
      服务器配置:2*E5 32核,96GB 内存,4*2TB 硬盘 RAID10 阵列.

      ¥99/月

    • 全球外贸服务器

      8核CPU

      32G内存

      1TB硬盘

      1000M带宽

      已部署数据中心:美国洛杉矶/亚特兰大、荷兰、加拿大、英国伦敦、德国、拉脱维亚、瑞典、爱沙尼亚
      自有机柜(全球九大数据中心),稳定在线率:99.9%

      ¥999/月 原价1380

    7*24小时 在线提交工单

    如果您的问题没有得到解决,推荐您在线提交工单,我们的客服人员会第一时间为您解决问题

    展开