【centOS】搭建公司内网git环境-GitLab 社区版(GitLab CE)

1. 安装必要的依赖

以 CentOS 7 系统为例,安装必要的依赖包:

bash 复制代码
sudo yum install -y curl policycoreutils openssh-server openssh-clients postfix
sudo systemctl start postfix
sudo systemctl enable postfix

2. 添加 GitLab 仓库

bash 复制代码
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

3. 安装 GitLab

bash 复制代码
sudo EXTERNAL_URL="http://192.168.153.139" yum install -y gitlab-ce

将 http://gitlab.example.com 替换为你实际的域名或 IP 地址。

4. 配置和启动 GitLab

bash 复制代码
sudo gitlab-ctl reconfigure

5. 访问 GitLab

在浏览器中输入你配置的 EXTERNAL_URL,首次访问时会要求你设置管理员密码。设置完成后,使用管理员账号登录即可开始创建项目和管理用户。

6. 常用命令

bash 复制代码
# 重启
sudo gitlab-ctl restart 
# 服务运行状态 查看
sudo gitlab-ctl status
# 配置文件路径
less /etc/gitlab/gitlab.rb
# 可以查看配置的地址信息
# 修改外部访问 URL:如果在安装时指定的 URL 有误或者后续需要更改,可以在 gitlab.rb 文件中找到 external_url 这一行,修改为正确的 URL

7. 防火墙配置

开放 GitLab 使用的端口(默认是 80 端口),允许外部访问:

bash 复制代码
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload
# 如果使用的是 HTTPS(端口 443),还需要开放 443 端口:
bash
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload

8 .配置邮件服务器

如果需要使用自定义的邮件服务器来发送通知邮件,可以在文件中添加或修改以下配置:

bash 复制代码
plaintext
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.example.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "your_email@example.com"
gitlab_rails['smtp_password'] = "your_email_password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = 'your_email@example.com'

将上述配置中的信息替换为你实际的邮件服务器信息。

也是修改 /etc/gitlab/gitlab.rb

9. 登录,修改root密码

密码要求,大小写,数字➕字母组成

user.password = 'Dxw2355661^'

user.password_confirmation = 'Dxw2355661^'

user.save

true就是成功了!

输入exit退出控制台

浏览器登陆,就会显示成功了!

Welcome to GitLab, Administrator!

相关推荐
极小狐3 天前
极狐GitLab万人并发架构实践,大规模组织的扩容路线图
架构·gitlab·极狐gitlab
Lvan的前端笔记4 天前
GitLab CI 环境变量整理
ci/cd·gitlab
李迟5 天前
CICD实例:解决GitLab Runner无法执行CICD问题
gitlab
hanjq_code7 天前
gitlab本地文件 跨分支 忽略改动 不提交
gitlab
极小狐7 天前
极狐GitLab集群高可用方案,多节点架构与故障自愈实践
架构·gitlab·高可用·极狐gitlab
极小狐8 天前
极狐GitLab主备同步延迟治理,复制滞后监控与优化方法
gitlab·极狐gitlab·geo容灾
极小狐8 天前
跨项目流水线报 404 Not Found?CI_JOB_TOKEN 允许名单 9 步排查
ci/cd·gitlab·devops·权限管理·流水线·极狐gitlab·作业令牌
极小狐9 天前
极狐GitLab双机热备搭建指南,主机备机部署与切换实操
gitlab·高可用·极狐gitlab
有同事要进步15 天前
如何在github或者是gitlab上创建空文件
gitlab·github
GoodStudyAndDayDayUp17 天前
gitlab私有化跑CICD
gitlab·gitlab私有化跑cicd