离线部署GitLab

本文档详细记录了在Windows服务器上使用虚拟机安装GitLab的过程,包括选择GitLab离线包、配置GitLab、修改外部URL、设置防火墙端口以及遇到的错误和解决方案。特别指出,配置GitLab时只需修改external_url,其他配置文件如puma和gitlab-http.conf不应手动修改,以免被覆盖。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、背景

公司是局域网开发环境,资源文件用svn管理,代码用git管理。

GitLab有点大,而且只能在Linux下使用,所以选择了轻巧的GitBlit。

后来GitBlit被暴漏洞,不让用,无奈只好再次选择GitLab。

二、调研

我们服务器是Windows系统,原准备用Docker,没弄明白,安装在Windows上跑不起来。于是改用虚拟机里装个Linux系统,再安装GitLab。

三、实操

1、GitLab离线包下载地址:

https://packages.gitlab.com/gitlab/gitlab-ce

注意要选相应系统版本和cpu架构的安装包。

2、虚拟机

下载了ubuntu server安装上,只有命令行,连查看ip都不行,更不要说将gitlab安装包复制进系统了。公司有kylin系统,于是直接用的kylin。

安装命令:

sudo dpkg -i gitlab-ce_14.9.3-ce.0_amd64.deb

结果如下:

 3、配置

修改下面的文件

sudo vi /etc/gitlab/gitlab.rb
external_url 'http://xx.xx.xx.xx:9999'    #根据自己情况修改

这里的IP地址,会体现在创建项目的ssh地址上。

Puma默认端口8080是注释掉的,这个端口不能跟external_url中的端口一样了,不然端口就冲突了。我调了一天的502,就是这个原因,我以为这俩得是一个端口。 

################################################################################
## GitLab Puma
##! Tweak puma settings.
##! Docs: https://docs.gitlab.com/ee/administration/operations/puma.html
################################################################################

# puma['enable'] = false
# puma['worker_timeout'] = 60
...

### Advanced settings
# puma['listen'] = '127.0.0.1'
# puma['port'] = 8080
...

上面这段配置不需要修改!! 

gitlab.rb配置文件中,只修改external_url即可。

注:有文章说Unicorn的端口与external_url中的一样,我不确定。我用的Puma,可能不一样。

4、配置生效

sudo gitlab-ctl reconfigure

结果如下:

 5、初始密码

初始密码保存地址:/etc/gitlab/initial_root_password

执行完上面的命令会有提示,如下:

...
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-password.

gitlab Reconfigured!

6、开启防火墙并放行端口(局域网可以不开启)

sudo ufw status # 1. 查看ufw的状态
sudo ufw enable # 2. 开启ufw
sudo ufw reload # 3. 重启防火墙ufw
sudo ufw allow 9999 # 4. 对外开启9999端口
sudo ufw status # 再查看开启端口状态

四、其他有用的命令

1、查看服务状态

sudo gitlab-ctl status

2、检查

sudo gitlab-rake gitlab:check

3、查看日志

sudo gitlab-ctl tail

4、重启

sudo gitlab-ctl restart

五、错误的操作

1、修改confiy.yml文件

该文件路径:/opt/gitlab/embedded/service/gitlab-shell/config.yml

config.yml提示,这个文件由gitlab-ctl管理,手工修改会被擦除,只能修改/etc/gitlab/gitlab.rb文件。如下:

# This file is managed by gitlab-ctl. Manual changes will be
# erased! Tochange the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.

...

2、修改gitlab-http.conf

文件地址:/var/opt/gitlab/nginx/conf/gitlab-http.conf

gitlab-http.conf提示,这个文件由gitlab-ctl管理,手工修改会被擦除,只能修改/etc/gitlab/gitlab.rb文件。如下:

# This file is managed by gitlab-ctl. Manual changes will be
# erased! Tochange the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.

...

参考文章:

如何搭建gitlab服务器——使用离线安装包部署 - 知乎

GitLab配置说明

GitLab初次安装后,登录GitLab网页的管理员账号和密码各是什么?_暗诺星刻的博客-CSDN博客_gitlab管理员账号

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

脱离语言

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值