CentOS7安装GitLab


系统配置

hostnamectl --static set-hostname git-server && su
setenforce 0 && sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
systemctl stop firewalld.service && systemctl disable firewalld.service && systemctl status firewalld.service
systemctl enable postfix && systemctl start postfix


安装gitlab

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install vim -y

vim /etc/yum.repos.d/gitlab_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 postfix cronie -y
head -1 /opt/gitlab/version-manifest.txt  
mkdir /gitdata
chown git.git /gitdata -R

CentOS7安装GitLab


配置gitlab

vim /etc/gitlab/gitlab.rb
#修改登陆地址
将external_url 'http://gitlab.example.com'更改成external_url 'http://你的地址'

#修改数据存放目录,592行后增加
git_data_dirs({  
   "default" => {
     "path" => "/gitdata"
    }
})

#550行后增加
gitlab_rails['manage_backup_path'] = true  
gitlab_rails['backup_path'] = "/gitdata/"  
gitlab_rails['backup_archive_permissions'] = 0644  
# gitlab_rails['backup_pg_schema'] = 'public'
###! The duration in seconds to keep backups before they are allowed to be deleted (7天)
gitlab_rails['backup_keep_time'] = 604800  

#GitLab Shell设置,612行后增加
gitlab_rails['gitlab_shell_ssh_port'] = 9022
gitlab_rails['gitlab_shell_git_timeout'] = 5000

#邮件配置,89行后增加
gitlab_rails['smtp_enable'] = true  
gitlab_rails['smtp_address'] = "smtp.qq.com"  
gitlab_rails['smtp_port'] = 25  
gitlab_rails['smtp_user_name'] = "git@vos.cn"  
gitlab_rails['smtp_password'] = "登陆密码"  
gitlab_rails['smtp_domain'] = "qq.com"  
gitlab_rails['smtp_authentication'] = "login"  
gitlab_rails['smtp_enable_starttls_auto'] = true  
gitlab_rails['smtp_tls'] = false  
### Email Settings
gitlab_rails['gitlab_email_enabled'] = true  
gitlab_rails['gitlab_email_from'] = 'git@vos.cn'  
gitlab_rails['gitlab_email_display_name'] = 'git'  
gitlab_rails['gitlab_email_reply_to'] = 'git@vos.com'  
gitlab_rails['gitlab_email_subject_suffix'] = 'gitlab' 
# gitlab_rails['admin_email_worker_cron'] = "0 0 * * 0"

gitlab-ctl reconfigure
#第一次访问要先修改登录密码,默认用户是root,如果再次修改配置,需要再执行gitlab-ctl restart

CentOS7安装GitLab


设置中文

CentOS7安装GitLab

右上角头像--Settings


CentOS7安装GitLab

Prefernces--Language--简体中文


备份

#测试备份
gitlab-rake gitlab:backup:create

#设置每晚11点定时备份
vim /etc/crontab
增加
0 23 * * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1

#恢复备份
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-rake gitlab:backup:restore 1610363545_2021_01_11_13.7.3_gitlab_backup.tar
gitlab-ctl restart



更新日期: 2021年01月11日
文章链接: https://www.vos.cn/os/477.html  
版权说明:如非注明,本站文章均为vOS原创,转载请注明出处和附带本文链接。