在 CentOS 上配置 GitLab,通常有两种常见方式:
下面我分别说明,最推荐第一种。
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
防火墙(如开启):
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
如果是社区版(免费):
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce
⚠️ 把
gitlab.example.com改成你的域名或服务器 IP
sudo gitlab-ctl reconfigure
访问:
http://服务器IP
首次登录账号:
rootcat /etc/gitlab/initial_root_password
配置文件:
/etc/gitlab/gitlab.rb
external_url 'http://192.168.1.100'
修改后执行:
sudo gitlab-ctl reconfigure
docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
访问:
http://服务器IP
external_url 'http://IP:8080'
nginx['listen_port'] = 8080
sudo gitlab-rake "gitlab:password:reset[root]"
sudo gitlab-ctl status
如果你告诉我:
我可以给你一份完全可执行的配置方案。