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帮助信息
相关推荐
IMPYLH4 分钟前
Linux 的 chmod 命令
linux·运维·服务器
迷茫青年18 分钟前
带你进入linux的世界,linux基础知识讲解
linux
艾莉丝努力练剑32 分钟前
【MYSQL】MYSQL学习的一大重点:数据库基础
linux·运维·服务器·数据库·c++·学习·mysql
会喷火才能叫火山36 分钟前
本地搭建AI相关步骤
linux·运维·ai·centos
齐齐大魔王37 分钟前
虚拟机网络无法连接
linux·网络·c++·python·ubuntu
_OP_CHEN40 分钟前
【MySQL数据库基础】(六)MySQL 表的约束详解:从基础到实战,拿捏数据合法性!
linux·数据库·mysql·c/c++·表约束·mysql表
淮北4941 小时前
tmux使用指南
linux·python·html·tmux·md
杨云龙UP1 小时前
Oracle DG / ADG日常巡检操作指南
linux·运维·服务器·数据库·ubuntu·oracle
L_09072 小时前
【Linux】进程控制
linux·运维·服务器
weixin_446260852 小时前
小而强大的文件系统,大大提高微控制器的稳定性
linux·服务器·网络