下面给你一份**在 Linux 上搭建 GitLab(社区版 CE)**的实用指南,适用于 Ubuntu / Debian / CentOS / RHEL 常见发行版。
# 更新系统
sudo apt update && sudo apt upgrade -y # Ubuntu/Debian
# 或
sudo yum update -y # CentOS
# 安装依赖
sudo apt install -y curl openssh-server ca-certificates postfix
# 添加 GitLab 源
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
# 安装 GitLab CE
sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ce
EXTERNAL_URL改成你的域名或 IP,如:
sudo EXTERNAL_URL="http://192.168.1.100" apt install gitlab-ce
sudo yum install -y curl policycoreutils openssh-server postfix
sudo systemctl enable sshd postfix
sudo systemctl start sshd postfix
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum install gitlab-ce
sudo gitlab-ctl reconfigure
完成后访问:
http://你的IP或域名
首次登录:
rootsudo cat /etc/gitlab/initial_root_password
sudo gitlab-ctl start # 启动
sudo gitlab-ctl stop # 停止
sudo gitlab-ctl restart # 重启
sudo gitlab-ctl status # 状态
sudo gitlab-ctl tail # 查看日志
编辑:
sudo vim /etc/gitlab/gitlab.rb
示例:
external_url 'http://gitlab.example.com'
nginx['listen_port'] = 8080
修改后:
sudo gitlab-ctl reconfigure
external_url 'https://gitlab.example.com'
letsencrypt['enable'] = true
然后:
sudo gitlab-ctl reconfigure
sudo ufw allow 80
sudo ufw allow 443
或 CentOS:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
prometheus_monitoring['enable'] = false
sudo gitlab-rake "gitlab:password:reset[root]"
如果你告诉我:
我可以给你一份完全定制化的安装命令。