Clay

用进废退 | 工字不出头

  • 主页
  • 归档
  • 随笔
  • 搜索
所有文章

Clay

用进废退 | 工字不出头

  • 主页
  • 归档
  • 随笔

Git之七-Centos7搭建Gitlab服务器

发表于:2019-01-10
字数统计:1k
阅读量统计:

Gitlab相关站点

  • Gitlab 官网
  • Gitlab CE Github
  • Gitlab 官方安装教程
  • Gitlab CE 官方文档
  • 安装Gitlab所需的最低硬件配置说明

Gitlab介绍

GitLab是基于Ruby on Rails的一个开源版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。GitLab 分为社区版(CE) 和企业版(EE)。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。依赖组件:Ruby、Git、Nginx、Redis、Sidekiq、GitLab Runner、Unicorn Workers、PostgreSQL/MySQL/MariaDB等,其中MySQL/MariaDB并不完全支持Gitlab的所有功能,官方强烈推荐安装PostgreSQL。

安装环境说明

1
2
3
4
5
$ uname -a
Linux centos7 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

安装并配置必要的依赖项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 安装依赖项
# yum install -y curl policycoreutils-python openssh-server

# 配置SSH服务开机自启动
# systemctl enable sshd

# 启动SSH服务
# systemctl start sshd

# 查看防火墙运行状态
# firewall-cmd --state

# 如果防火墙服务处于关闭状态,则启用防火墙服务
# systemctl start firewalld

# 配置防火墙开放HTTP服务(80端口)
# firewall-cmd --permanent --add-service=http

# 保存防火墙配置
# systemctl reload firewalld

# 查看防火墙已开放的服务,防火墙默认会开放SSH服务(22端口)
# firewall-cmd --list-services
dhcpv6-client ssh http

安装Postfix,用于发送通知邮件

1
2
3
4
5
6
7
8
# 安装Postfix
# yum install postfix

# 配置Postfix服务开机自启动
# systemctl enable postfix

# 启动Postfix服务
# systemctl start postfix

Yum方式安装Gitlab

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 添加Yum仓库
# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

# 安装Gitlab,EXTERNAL_URL是指用于外部访问Gitlab的域名或者URL地址,安装包的体积约447M
# EXTERNAL_URL="http://192.168.1.198" yum install -y gitlab-ce

# 编译Gitlab的配置与启动Gitlab,首次执行耗时较长
# gitlab-ctl reconfigure

# 查看gitlab各组件是否启动成功
# gitlab-ctl status

# 查看已安装的Gitlab的版本
# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

# 测试Gitlab是否安装并启动成功,浏览器输入以下URL访问Gitlab,初次访问Gitlab需要在Web界面配置root用户的密码,然后使用root用户进行登录
http://192.168.1.198

配置Gitlab的Nginx端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 不能通过编辑Nginx配置文件的方式来修改Gitlab的Nginx端口,因为重新编译Gitlab的配置后,Nginx的配置文件/var/opt/gitlab/nginx/conf/gitlab-http.conf会被重新覆盖

# 编辑Gitlab的配置文件
# vim /etc/gitlab/gitlab.rb

# 修改Gitlab的Nginx端口(默认80),注意不要用8082端口,因为自带工具可能会占用
nginx['listen_port'] = 8888
external_url 'http://192.168.1.198:8888'

# 重新编译Gitlab的配置,Nginx配置文件中的listen、server_name、http_host_with_default配置项的值会自动更新
# gitlab-ctl reconfigure

# 重启GitLab
# gitlab-ctl restart

# 配置防火墙永久开放修改后的Nginx端口
# firewall-cmd --zone=public --permanent --add-port=8888/tcp

# 保存防火墙配置
# firewall-cmd --reload

# 查看防火墙已开放的端口
# firewall-cmd --list-ports

Gitlab常用目录与配置文件介绍

1
2
3
4
5
6
7
8
9
10
11
# 对应Gitlab各服务的主目录,同时也是Gitlab的数据目录
# ls /var/opt/gitlab

# 对应各服务的日志目录
# ls /var/log/gitlab

# 配置文件-Gitlab
# cat /etc/gitlab/gitlab.rb

# 配置文件-Nginx
# cat /var/opt/gitlab/nginx/conf/gitlab-http.conf

Gitlab常用命令介绍

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 启动所有gitlab组件
# gitlab-ctl start

# 停止所有gitlab组件
# gitlab-ctl stop

# 重启所有gitlab组件
# gitlab-ctl restart

# 查看gitlab各组件的运行状态
# gitlab-ctl status

# 重启某个组件
# gitlab-ctl restart nginx

# 查看某个组件的运行状态
# gitlab-ctl status nginx

# 重新编译gitlab的配置
# gitlab-ctl reconfigure

# 查看gitlab的日志
# gitlab-ctl tail

# 查看nginx的日志
# gitlab-ctl tail nginx/gitlab_access.log

# 检查gitlab
# gitlab-rake gitlab:check SANITIZE=true --trace

下篇 - Git之八-Gitlab详细使用教程

本文作者: Clay
发布时间: 2019-01-10 21:13:25
本文链接: https://www.techgrow.cn/posts/37ea711c.html
版权声明: 本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。转载请注明出处!
赏

谢谢你的支持

支付宝
微信
  • Centos
  • 版本控制

扫一扫,分享到微信

微信分享二维码
Python开发知识图谱(最新)
Git之六-使用Gitolite搭建Git服务器
© 2021 Clay
本站总访问量  人次
载入天数...载入时分秒...
粤ICP备19024664号
  • 所有文章

显示标签:

  • AI
  • C/C++
  • CI/CD
  • CentOS
  • Centos
  • Docker
  • HarmonyOS
  • Java
  • Linux
  • Manjaro
  • Python
  • Web服务器
  • 企业面试
  • 分布式
  • 前端
  • 区块链
  • 开发工具
  • 开源
  • 微服务
  • 数据库
  • 架构
  • 树莓派
  • 爬虫
  • 版本控制
  • 知识图谱
  • 算法与数据结构
  • 缓存
  • 网络攻防
  • 随笔

    [^_^] 出错啦!请重新刷新页面!