推荐宝塔 -> 软件商店 -> GitLab最新社区版
修改域名或者内网IP(可加端口号)
sudo vi /etc/gitlab/gitlab.rb
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://xxx.xxx.xxx.xxx'
1、Gitlab备份配置修改。设定备份路径,备份权限以及备份保留时间。
sudo vi /etc/gitlab/gitlab.rb
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/home/gitlab/backups" //gitlab备份目录
gitlab_rails['backup_archive_permissions'] = 0644 //生成的备份文件权限
gitlab_rails['backup_keep_time'] = 7776000 //备份保留时间,秒计算 7776000 = 3600*24*30*3 = 90天
2、启动定时任务,每天凌晨2点进行备份。
sudo vi /etc/crontab
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 2 * * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create
3、Ubuntu 系统启动定时任务,systemctl restart cron
1、修改启动脚本sudo vi /opt/gitlab/sv/nginx/run
#!/bin/sh
exec 2>&1
cd /var/opt/gitlab/nginx
exec chpst -P /opt/gitlab/embedded/sbin/gitlab-web -p /var/opt/gitlab/nginx
2、重新启动gitlab-ctl restart
| 指令 | 作用 |
|---|---|
| sudo gitlab-ctl reconfigure | 重新加载配置,每次修改/etc/gitlab/gitlab.rb文件之后执行 |
| sudo gitlab-ctl status | 查看 GitLab 状态 |
| sudo gitlab-ctl start | 启动 GitLab |
| sudo gitlab-ctl stop | 停止 GitLab |
| sudo gitlab-ctl restart | 重启 GitLab |
| sudo gitlab-ctl tail | 查看所有日志 |
| sudo gitlab-ctl tail nginx/gitlab_acces.log | 查看 nginx 访问日志 |
| sudo gitlab-ctl tail postgresql | 查看 postgresql 日志 |