温馨提示×

ubuntu上gitlab配置指南

小樊
39
2025-08-28 01:23:28
栏目: 智能运维

以下是在Ubuntu上配置GitLab的指南:

安装依赖

更新系统并安装必要依赖包:

sudo apt update sudo apt install -y curl openssh-server ca-certificates postfix 

在postfix安装过程中,选择“Internet Site”并输入服务器主机名。

添加仓库并安装GitLab

添加GitLab官方仓库:

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash 

安装GitLab:

sudo apt install gitlab-ce 

配置GitLab

编辑配置文件/etc/gitlab/gitlab.rb

sudo vim /etc/gitlab/gitlab.rb 

找到external_url字段,修改为服务器IP或域名,如external_url 'http://192.168.1.100'。如需配置邮件服务,可设置gitlab_rails['smtp_enable']等相关参数。

应用配置并启动服务

sudo gitlab-ctl reconfigure sudo gitlab-ctl restart 

配置防火墙(可选)

若启用防火墙,允许HTTP、HTTPS和SSH端口:

sudo ufw allow http sudo ufw allow https sudo ufw allow ssh sudo ufw enable 

访问GitLab

在浏览器中输入配置的external_url,首次访问需用root用户和/etc/gitlab/initial_root_password文件中的密码登录。

0