gitlab快速部署教程

部署环境

  • Ubuntu 16.04(亲测可用)

开始部署

安装依赖

sudo apt-get install curl openssh-server ca-certificates postfix

执行完成后,出现邮件配置,选择Internet那一项(不带Smarthost的)

下载软件包

下载页面: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/xenial/main/g/gitlab-ce/

可以自行选择想要部署的版本,使用命令curl进行下载

curl -O https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/xenial/main/g/gitlab-ce/gitlab-ce_11.3.6-ce.0_amd64.deb

安装软件包

sudo dpkg –i gitlab-ce_11.3.6-ce.0_amd64.deb

如果安装过程出现错误则需要自行解决依赖等问题(笔者安装时一切正常)

配置生成

sudo gitlab-ctl reconfigure

初次安装使用请一定记得生成配置

检查

输入以下命令检查是否安装正确

sudo gitlab-ctl status

出现类似以下的结果,则说明运行正常

run: gitlab-workhorse: (pid 1148) 884s; run: log: (pid 1132) 884s
run: logrotate: (pid 1150) 884s; run: log: (pid 1131) 884s
run: nginx: (pid 1144) 884s; run: log: (pid 1129) 884s
run: postgresql: (pid 1147) 884s; run: log: (pid 1130) 884s
run: redis: (pid 1146) 884s; run: log: (pid 1133) 884s
run: sidekiq: (pid 1145) 884s; run: log: (pid 1128) 884s
run: unicorn: (pid 1149) 885s; run: log: (pid 1134) 885s

使用

使用的时候,系统管理员账户名称为root,需要先设置一个root账户密码。

如果出现502错误的话,则将以下文件的读权限打开

sudo chmod -R o+x /var/opt/gitlab/gitlab-rails

配置调整

部署域名调整

编辑配置文件

sudo nano /etc/gitlab/gitlab.rb

将内部的external_url修改为自己的部署域名,例如:

  • 如果是局域网直接ip访问的话,设置为http://xxx.xxx.xxx.xxx即可
  • 如果是外网通过域名访问的话,设置为http://your.domain-name.com

然后,重新生成配置

sudo gitlab-ctl reconfigure

自行使用nginx部署

实际上,这个快速部署的软件包内是自带nginx的,然而实际服务器部署的话,我们常常需要部署在系统原生的nginx上,我们可以按照这样的方式进行操作:

在nginx配置文件中添加配置:

# gitlab socket 文件地址
upstream gitlab {
# 7.x 版本在此位置
# server unix:/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket;
# 8.0+ 版本位置(11.x版本亲测可用)
server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
} server {
listen *:80; server_name gitlab.liaohuqiu.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;
}

编辑gitlab配置文件

sudo nano /etc/gitlab/gitlab.rb

禁用掉自带的nginx(如果原本没有这句话的话需要加上)

nginx['enable'] = false

重启nginx,重启gitlab服务

sudo /usr/local/nginx/sbin/nginx -s reload
sudo gitlab-ctl reconfigure

同样的,如果再次出现502错误的话,需要修改一下配置

sudo chmod -R o+x /var/opt/gitlab/gitlab-rails

【gitlab】gitlab快速部署教程的更多相关文章

  1. Hexo快速部署教程

    一直有建立博客的需要,使用过Wordpress动态博客,一直访问速度比较慢,刚开始以为是空间域名的解析的问题,尝试使用Hexo静态博客,部署后感觉速度正常很多,特意发文快速部署教程 准备 本文是在wi ...

  2. Gitlab环境快速部署(RPM包方式安装)

    之前梳理了一篇Gitlab的安装CI持续集成系统环境---部署Gitlab环境完整记录,但是这是bitnami一键安装的,版本比较老.下面介绍使用rpm包安装Gitlab,下载地址:https://m ...

  3. ubuntu快速部署gitlab汉化容器

    前言:gitlab的原理我就不扯了(看这个https://www.jianshu.com/p/567207ac51cd),下面直接上操作 1.前提: a.要有docker的运行环境,用service ...

  4. docker-compose 快速部署持续集成测试环境 Gitlab+Harbor+Jenkins pipeline 实现 tag run docker Images

    环境 测试部署主机IP:192.168.1.1 Jenkins主机IP:192.168.1.2 Harbor主机IP:192.168.1.3 Gitlab主机IP:192.168.0.10 系统信息: ...

  5. 使用Docker快速部署Gitlab

    使用Docker部署Gitlab 1. 下载gitlab镜像 docker pull gitlab/gitlab-ce 2. 运行gitlab实例 GITLAB_HOME=`pwd`/data/git ...

  6. Gitlab 快速部署及日常维护 (二)

    一.概述 上一篇我们将Gitlab的安装部署和初始化设置部分全部讲解完成了,接下来我们介绍Gitlab在日常工作中常遇见的问题进行梳理说明. 二.Gitlab的安装和维护过程中常见问题 1.Gitla ...

  7. Gitlab 快速部署及日常维护 (一)

    一.GitLab简介GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务 二.GitLab系统架构git用户的主目录通常是/home/git(~ ...

  8. Docker快速部署gitlab

    环境: Centos7.5 安装Docker 1.移除旧版本: $ sudo yum remove docker \ docker-client \ docker-client-latest \ do ...

  9. Gitlab CI 自动部署 asp.net core web api 到Docker容器

    为什么要写这个? 在一个系统长大的过程中会经历不断重构升级来满足商业的需求,而一个严谨的商业系统需要高效.稳定.可扩展,有时候还不得不考虑成本的问题.我希望能找到比较完整的开源解决方案来解决持续集成. ...

随机推荐

  1. 隐写术之steghide的使用

    steghide不是一个软件,所以下载之后解压缩就可以在命令行中使用. win+R,cmd,回车->进入到steghide.exe所在的文件夹,使用隐藏或者解锁的相应命令,即可隐藏或者解锁. 这 ...

  2. 解决在使用gensim.models.word2vec.LineSentence加载语料库时报错 UnicodeDecodeError: 'utf-8' codec can't decode byte......的问题

    在window下使用gemsim.models.word2vec.LineSentence加载中文维基百科语料库(已分词)时报如下错误: UnicodeDecodeError: 'utf-8' cod ...

  3. sys系统模块

    import sys # print(0)## sys.exit(0)## print(123) # print(sys.version)# print(sys.maxsize)# print(sys ...

  4. 试试Linux下的ip命令,ifconfig已经过时了

    linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...

  5. 使用py,根据日志记录自动生成周报

    日志格式如下,思路是如果检测到文件中的内容为5位或者8位,即12.11或18.12.11,同时存在.即认为当前行为日期数据仅作为方便查看日志使用,生成脚本时过滤此行.每次读取到空白行的时候则认为下一条 ...

  6. ansible copy 模块详解

    ansible 模块 copy one.概述 copy 模块的作用就是拷贝文件,它与之前介绍过的 fetch 模块类似,不过,fetch 模块是从远程主机中拉取文件到 ansible 管理主机,而 c ...

  7. Pyhon进阶9---类的继承

    类的继承 基本概念 定义 格式如下 继承中的访问控制 class Animal: __CNOUT = 0 HEIGHT = 0 def __init__(self,age,weight,height) ...

  8. LODOP打印超过后隐藏内容样式

    Lodop中的有纯文本和超文本,纯文本本身超过设置的打印项宽度,如果高度足够,就会换行,如果高度设置的很小,不会换行,后面的内容会直接隐藏.除非设置了多页项等,会自动分页.超文本打印项需要用css样式 ...

  9. Java单例模式的实现

    单例的实现 单例设计模式的问题 1.      线程安全问题用synchronized修饰实例化部分代码 2.      性能问题–采用懒汉式实例化 3.      指令重排序问题–用volatile ...

  10. showdoc app接口文档编写利器

    通过朋友介绍,才知道有这么好的一个在线接口编写文档开源项目,非常感谢原作者的贡献 ShowDoc介绍 关于ShowDoc的介绍,请访问:http://blog.star7th.com/2015/11/ ...