CentOS7下yum安装GitLab-CE
前提准备
建立git用户
useradd git
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
安装依赖库
yum install curl openssh-server postfix cronie -y
service postfix start
chkconfig postfix on
配置yum源进行安装
注意: gitlab-ce 镜像仅支持 x86-64 架构
centos中可以直接通过配置yum源然后使用yum进行一键安装
国内可以使用的清华大学的镜像源安装GitLab,相关配置及安装参照:https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
以下内容写入yum源配置文件:/etc/yum.repos.d/gitlab-ce.repo
# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
yum makecache
yum install gitlab-ce #自动安装最新版
# yum install gitlab-ce-x.x.x #安装指定版本
# 安装成功后的提示:
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
默认路径
一键安装后可以利用rpm -ql gitlab-ce查询其文件安装路径及相关文件路径,其默认安装路径为/opt/gitlab/、程序数据及配置文件保存路径为/var/opt/gitlab下。
代码仓库保存位置:/var/opt/gitlab/git-data/repositories/
代码仓库备份位置:/var/opt/gitlab/backups/
postgresql数据及配置目录:/var/opt/gitlab/postgresql/data/
redis默认配置目录:/var/opt/gitlab/redis
gitlab主要配置文件:/etc/gitlab/gitlab.rb
常见配置
修改gitlab运行外部URL默认的访问地址
编辑/etc/gitlab/gitlab.rb
# 未修gitlab.rb配置文件中nginx配置时这个配置默认配置gitlab自带的nginx端口
external_url 'http://172.17.17.10:81'
修改之后使用如下命令重新加载配置且同时启动gitlab所有服务:
gitlab-ctl reconfigure
浏览器访问:http://172.17.17.10:81,被重定向到密码修改界面,修改密码为root的管理员账户,修改密码后自动跳转到登录页面,用root和修改后密码登录就可以
GitLab常用命令
gitlab-ctl start # 启动所有 gitlab 组件
gitlab-ctl stop # 停止所有 gitlab 组件
gitlab-ctl restart # 重启所有 gitlab 组件
gitlab-ctl status # 查看服务状态
gitlab-ctl reconfigure # 启动服务
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab
sudo gitlab-ctl tail # 查看日志
gitlab-ctl --help #查看更多命令
发送邮件配置
gitlab_rails['smtp_enable'] = true #启用smtp服务
gitlab_rails['smtp_address'] = "mail.ultrapower.com.cn" #smtp发送服务器
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "xueming@ultrapower.com.cn"
gitlab_rails['smtp_password'] = "12333lzxcl"
gitlab_rails['smtp_domain'] = "ultrapower.com.cn"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = 'xueming@ultrapower.com.cn'#与smtp_user_name一定要一样
gitlab_rails['gitlab_email_reply_to'] = 'xueming@ultrapower.com.cn'
命令测试:gitlab-rails console
防火墙开放端口
firewall-cmd --zone=public --list-ports #查看开放端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent #开放8081端口
firewall-cmd --reload #重新加载配置
#如果不需要,也可以直接关闭防火墙
systemctl stop firewalld.service
设置中文界面
刷新界面,就是中文的了
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)