1、安装依赖服务
yum install curl policycoreutils-python openssh-server postfix -y
systemctl start postfix
systemctl enable postfix
2、新增yum源
# 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
3、安装
yum makecache
yum -y install gitlab-ce
yum -y install gitlab-ce-8.9.5 # 安装指定版本
4、配置url并启动服务
# 修改url地址
vim /etc/gitlab/gitlab.rb
external_url 'http://www.herlly.org'
# 初始化并启动服务
gitlab-ctl reconfigure
gitlab-ctl start
5、备份
# 修改gitlab的备份路径
vim /etc/gitlab/gitlab.rb
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/data/gitlab/backups"
gitlab_rails['backup_keep_time'] = 1728000 # 文件保留20天(单位:s)
# 重新加载配置
gitlab-ctl reconfigure
# 备份
gitlab-rake gitlab:backup:create # 备份完成,会在"/data/gitlab/backups"目录下生成相应的文件
6、恢复
# 为保证数据的一致性先停止数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
# 恢复命令,版本不一样,可能名称有区别。
gitlab-rake gitlab:backup:restore BACKUP=/var/opt/gitlab/backups/1560758230_2019_06_1
# # 启动刚才的服务,或者重启gitlab(gitlab-ctl restart)。
gitlab-ctl start unicorn
gitlab-ctl start sidekiq
7、关闭注册功能
第一次登陆设置新密码
8、关闭注册入口
效果
9、nginx代理访问
# gitlab.conf
server { listen 80; server_name gitlab.herlly.cn; access_log /var/log/nginx/gitlab-herlly-cn.log main;
set $web_url $host;
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot")
{
return 404;
}
location / {
proxy_pass http://192.168.1.1;
include /etc/nginx/conf.d/deny.conf;
proxy_redirect default;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $domain default;
}
}