使用yum安装并配置GitLab
安装
# 安装依赖工具
sudo yum install -y curl policycoreutils-python openssh-server
# 启用SSH服务
sudo systemctl enable sshd
sudo systemctl start sshd
# 安装邮件服务
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
# 配置国内镜像源,清华大学镜像源
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缓存并安装GitLab
sudo yum makecache
sudo yum -y install gitlab-ce
配置GitLab
# 编辑/etc/gitlab/gitlab.rb文件,修改external_url为服务器的域名或IP地址
vim /etc/gitlab/gitlab.rb
external_url 'http://xx.xx.xx.xx'
# 配置gitlab使用https
vim /etc/gitlab/gitlab.rb
letsencrypt['enable'] = true # 启用Let's Encrypt
letsencrypt['contact_emails'] = ['[email protected]']
external_url 'https://xx.xx.xx.xx'
# 重新加载配置文件
gitlab-ctl reconfigure
gitlab-ctl show-config # 验证配置文件
配置邮件功能
vim /etc/gitlab/gitlab.rb
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_display_name'] = 'gitlab'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.126.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "lixun"
gitlab_rails['smtp_password'] = "mypassword"
gitlab_rails['smtp_domain'] = "126.com"
gitlab_rails['smtp_authentication'] = "login"
也可以在GitLab Web页面配置 "Settings" -> "Integrations" -> "Email notifications" -> "Enable" 开启邮件服务
在对话框中填写相关的邮件设置信息(这些设置通常会根据/etc/gitlab/gitlab.rb中的信息自动填充)
使用Docker安装并配置GitLab
安装
# 创建用于存储GitLab配置、数据和日志的目录。
mkdir -p /docker/gitlab/{config,data,logs}
# 拉取GitLab镜像
docker pull gitlab/gitlab-ce:latest # 或指定版本,如 gitlab/gitlab-ce:15.3.1-ce.0
# 运行GitLab容器
docker run -d \
-p 8888:80 \
-p 2222:22 \
-v /docker/gitlab/config:/etc/gitlab \
-v /docker/gitlab/data:/var/opt/gitlab \
-v /docker/gitlab/logs:/var/log/gitlab \
--restart always \
--name gitlab \
gitlab/gitlab-ce:latest /bin/bash
# 查看GitLab初始密码
docker exec -it gitlab grep "Password:" /etc/gitlab/initial_root_password
使用初始密码登录GitLab,并设置新的密码和其他配置。
配置GitLab
登录GitLab后,根据需求配置访问控制、关闭用户自动注册等功能。
标签:配置,Gitlab01,gitlab,rails,etc,xx,yum,安装,GitLab From: https://www.cnblogs.com/lixunblogs/p/18244302