以下是GitLab在Ubuntu上的网络配置指南:
更新系统:sudo apt update && sudo apt upgrade -y
。安装依赖包:sudo apt install -y curl openssh-server ca-certificates tzdata perl
。
添加GitLab仓库:curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
。安装GitLab:sudo apt install gitlab-ce -y
。
编辑/etc/gitlab/gitlab.rb
,设置external_url
为域名或IP,如external_url 'http://yourdomain.com'
。若要修改监听端口,可设置unicorn['listen_port']
等参数。保存后执行sudo gitlab-ctl reconfigure
和sudo gitlab-ctl restart
。
若使用UFW,开放所需端口:sudo ufw allow 80/tcp
、sudo ufw allow 443/tcp
、sudo ufw allow 22/tcp
,然后启用防火墙:sudo ufw enable
。
使用Let’s Encrypt获取证书:sudo apt install certbot python3-certbot-nginx
,sudo certbot --nginx -d yourdomain.com
。编辑/etc/gitlab/gitlab.rb
配置证书路径,再执行sudo gitlab-ctl reconfigure
和sudo gitlab-ctl restart
。