1.按照官网流程走一遍:https://about.gitlab.com/install/#centos-7
在CentOS 7(和RedHat / Oracle / Scientific Linux 7)上,以下命令还将在系统防火墙中打开HTTP和SSH访问。
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 systemctl reload firewalld
接下来,安装Postfix以发送通知电子邮件。如果要使用其他解决方案发送电子邮件,请跳过此步骤并在安装GitLab后配置外部SMTP服务器。
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
在Postfix安装期间,可能会出现配置屏幕。选择“Internet Site”并按Enter键。使用服务器的外部DNS作为“邮件名称”,然后按Enter键。如果出现其他屏幕,请继续按Enter键接受默认值。
2.添加GitLab软件包存储库并安装软件包
添加GitLab包存储库。
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
接下来,安装GitLab包。更改https://gitlab.example.com
为您要访问GitLab实例的URL。安装将自动配置并启动该URL的GitLab。
对于https://
URL,GitLab将自动使用Let's Encrypt请求证书,该证书需要入站HTTP访问和有效的主机名。您也可以使用自己的证书或只使用http://。
sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ee
2.添加端口&修改端口
添加8888和8887端口,并修改gitlab默认访问端口
添加端口
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --zone=public --add-port=8887/tcp --permanent
firewall-cmd --reload
gitlab默认是80端口,如果存在端口冲突,需要修改端口,如果不存在端口冲突,则不需要。
3.修改/etc/gitlab/gitlab.rb
sudo vim /etc/gitlab/gitlab.rb 或者 vim /etc/gitlab/gitlab.rb
按i键,进入编辑模式,修改external_url后面的内容为:
external_url 'http://192.168.10.200:8888'
添加:
nginx['listen_port'] = 8888
unicorn['port'] = 8887
按Esc键,推出编辑模式
输入":wq"按回车,保存gitlab.rb的内容
4.重置并启动GitLab
gitlab-ctl reconfigure
gitlab-ctl restart
5.内网找一台电脑尝试访问,看到登录界面,则说明搭建成功:根据上面的配置,我的gitlab地址是 192.168.10.200:8888