CentOS 7.x 使用 RPM 包安装 Gitlab

复制代码
官网:https://about.gitlab.com/
https://about.gitlab.cn/install/
安装:https://gitlab.cn/install/
博客:https://gitlab.cn/blog/
文档:https://docs.gitlab.com/
https://about.gitlab.com/install/#centos-7
https://docs.gitlab.com/ee/install/requirements.html
复制代码
官方下载:https://packages.gitlab.com/gitlab/gitlab-ce
国内镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
教程:https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/install/centos
https://docs.gitlab.cn/omnibus/installation/
【安装环境要求】
复制代码
CPU:建议使用双核或以上的CPU
内存:建议使用4GB或以上内存,内存最小4GB (gitlab need 3GB+)
硬盘:建议使用至少50GB的硬盘空间,如果需要使用git-lfs,则建议使用100GB或以上的硬盘空间
操作系统:建议使用Linux操作系统,推荐使用Ubuntu或CentOS操作系统
网络要求:开放端口TCP-80和TCP-443端口,TCP-22端口用于SSH访问。如果使用HTTP协议,则需要开放TCP-81端口
         TCP-25端口用于SMTP邮件服务

注意:自从gitlab12.1开始,后端存储不再支持mysql,而是仅支持一种数据PostgreSQL
【配置主机名与ip地址】
复制代码
cd /etc/sysconfig/network-scripts/
vim /etc/hostname

设置主机名为:gitlab-server

如果是个人本地虚拟机安装,则配置win10的hosts文件,配置gitlab-server的ip映射关系
【安装依赖】
复制代码
sudo yum -y update
sudo yum install -y curl openssl-devel policycoreutils-python openssh-server perl rsync
sudo systemctl enable sshd
sudo systemctl start sshd
sudo systemctl start firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
【下载/安装GitLab】
复制代码
https://archlinux.org/packages/?q=gitlab
https://packages.gitlab.com/gitlab/gitlab-ce

wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.12.15-ce.0.el7.x86_64.rpm/download.rpm
【编写安装脚本】
复制代码
# vim gitlab-install.sh

sudo rpm -ivh /path-to/gitlab-ce-13.12.15-ce.0.el7.x86_64
sudo yum install -y curl policycoreutils-python openssh-server perl cronie
sudo lokkit -s http -s ssh

sudo yum install -y postfix
sudo systemctl enable postfix
sudo systemctl start postfix

# 配置GitLab 软件源镜像 - 如果是离线安装,这一步可以省略
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce
【给脚本赋予执行权限 - 执行安装】
复制代码
添加脚本执行权限:chmod +x gitlab-install.sh
执行脚本安装gitlab:./gitlab-install.sh
安装:sudo yum install gitlab-ce-13.12.15-ce.0.el7.x86_64 -y
查看版本:cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
【配置gitlab】
复制代码
配置参考:https://gitlab.com/gitlab-org/gitlab-recipes/-/blob/master/web-server/nginx/gitlab-omnibus-nginx.conf

安装成功后,修改ip和端口

命令:vim /etc/gitlab/gitlab.rb

修改 external_url ,将 http://gitlab.example.com 换成自己的 ip 或域名,如:http://IP:端口,一定要带上协议!

默认端口:80
【初始化gitlab服务】
复制代码
# 初始化配置 - 重新加载配置文件
sudo gitlab-ctl reconfigure   -- 命令执行成功显示:gitlab Reconfigured!

sudo gitlab-ctl start
sudo gitlab-ctl restart
sudo gitlab-ctl stop
sudo gitlab-ctl status

控制台命令: gitlab-rails console
退出控制台:quit
【登录修改root账号的密码】
复制代码
参考:https://docs.gitlab.cn/omnibus/installation/

cat /etc/gitlab/initial_root_password

登录:浏览器输入ip:port   -- 首次登录要消耗一点时间,耐心等一下
登录成功会直接跳转到修改root密码界面
设置密码:Admin123

修改密码后再次登录,禁用注册功能:http://123.60.171.255/help/user/admin_area/settings/sign_up_restrictions
【安装Runner - 可选项】
复制代码
安装参考:https://docs.gitlab.com/runner/install/
【运维常用命令】
复制代码
gitlab-ctl start #启动全部服务
gitlab-ctl restart#重启全部服务
gitlab-ctl stop #停止全部服务
gitlab-ctl restart nginx #重启单个服务,如重启nginx
gitlab-ctl status #查看服务状态
gitlab-ctl reconfigure #使配置文件生效
gitlab-ctl show-config #验证配置文件
gitlab-ctl uninstall #删除gitlab(保留数据)
gitlab-ctl cleanse #删除所有数据,从新开始
gitlab-ctl tail <service name>查看服务的日志
gitlab-ctl tail nginx #如查看gitlab下nginx日志
gitlab-rails console #进入控制台
gitlab-ctl help #查看gitlab帮助信息
相关推荐
likfishdn21 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean40 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=42 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙2 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构
Mr.pyZhang4 小时前
Android构建系统 - 04 编译产物
android·linux