CentOS 7.9 中安装 GitLab
基于 CentOS 7.9 和 GitLab 官方仓库脚本 安装/配置 GitLab
参考文档
- GitLab 官网 CentOS 安装文档,使用国内IP访问时,会跳转到极狐GitLab
- 极狐GitLab CentOS 安装文档
- 极狐GitLab 中文文档
- GitLab 升级路径工具
- 自签名证书或自定义证书颁发机构
说明
- FramaGit
- 本文以 GitLab EE 为例
- 本文使用的域名是IP 192.168.80.14(原因:如果使用域名,必须拥有这个域名的所有权,并增加解析才可以,要不然在 Docker 容器中,无法使用域名检出代码,因为根据域名找不到DNS记录)
安装 GitLab
安装语句自动补全软件
shellyum -y install bash-completion source /etc/profile
安装必要依赖
shell# 安装必要的依赖 # 参见文档: # https://about.gitlab.com/install/#centos-7 # https://gitlab.cn/install/#centos-7 # https://packages.gitlab.com/gitlab/gitlab-ee/packages/el/7/gitlab-ee-15.5.4-ee.0.el7.x86_64.rpm # CentOS 7 sudo yum install -y curl policycoreutils-python openssh-server perl # CentOS 8 # sudo yum install -y curl policycoreutils-python-utils openssh-server perl sudo systemctl enable sshd sudo systemctl start sshd # 开启 http 端口:GitLab 默认端口 # 开启 https 端口:GitLab 默认端口 sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https # 重载防火墙 sudo systemctl reload firewalld # 查看防火墙已开放的端口与服务 sudo firewall-cmd --list-all
安装 Postfix 用于发送邮件(可选)
- 用户使用新IP登录时发送邮件
- 用户使用邮件找回密码
- 用户PR邮件提示等
shellsudo yum -y install postfix sudo systemctl enable postfix sudo systemctl start postfix
配置 GitLab EE 软件源镜像
shellcurl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
下载安装 GitLab EE
shellsudo EXTERNAL_URL="http://192.168.80.14" yum install -y gitlab-ee # 或者使用 # sudo yum install -y gitlab-ee # 由于上述安装命令未指定域名,需要手动执行一次配置 # sudo gitlab-ctl reconfigure # 或者使用 # 可以指定域名安装,避免手动配置 # sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee
查看管理员 root 用户的默认密码
shell# 用户名为 root sudo cat /etc/gitlab/initial_root_password
修改密码,网址:
http://GitLab服务器IP/-/profile/password/edit
,或修改DNS(也可以是本地hosts 文件)后,使用: http://192.168.80.14/-/profile/password/edit将语言调整为中文,网址:
http://GitLab服务器IP/-/profile/preferences
,将 Language 修改为 Chinese, Simplified - 简体中文,刷新页面即可显示中文至此,GitLab就安装完成了。
相关命令
查看GitLab状态
shellsudo systemctl status gitlab-runsvdir.service
停止GitLab
shellsudo systemctl stop gitlab-runsvdir.service
重启GitLab
shellsudo systemctl restart gitlab-runsvdir.service
启动GitLab
shellsudo systemctl start gitlab-runsvdir.service
查看GitLab开机自启状态
shellsudo systemctl list-unit-files | grep gitlab-runsvdir.service
关闭GitLab开启自启
shellsudo systemctl disable gitlab-runsvdir.service
开启GitLab开启自启
shellsudo systemctl enable gitlab-runsvdir.service
查看 GitLab 各服务的状态
shellsudo gitlab-ctl status