GitLab通俗理解就是相当于个人版的GitHub,GitHub是将代码托管在公共服务期上的代码托管平台,而GitLab则是将代码托管在私有服务器上,所以GitLab更适合公司,团队的代码托管服务。
本文记录GitLab的搭建,搭建环境为CentOS 8 虚拟机。
- 安装依赖
# 安装依赖软件
yum install -y policycoreutils-python-utils policycoreutils openssh-server openssh-clients postfix
# 启动ssh服务并设置开机自启
systemctl enable sshd && systemctl start sshd
# 启动postfix服务并设置开机自启,postfix支持GitLab发信功能
systemctl enable postfix && systemctl start postfix
# 开放ssh以及http的防火墙并重新加载
firewall-cmd --add-service=ssh --permanent
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
- 下载GitLab的rpm包
在清华镜像站下载GitLab的rpm包,然后使用一下命令安装
rpm -ivh gitlab-ce-13.6.3-ce.0.el8.x86_64.rpm (具体软件包名称可能会有差别)
- 修改GitLab配置
vi /etc/gitlab/gitlab.rb
# 更改GitLab访问链接和端口,默认端口为80,改为82
external_url 'http://192.168.66.100:82'
nginx['listen_port'] = 82
- 重载配置并启动gitlab
# 重载配置,需要一会时间
gitlab-ctl reconfigure
# 启动gitlab
gitlab-ctl restart
- 添加防火墙放行82端口
firewall-cmd --zone=public --add-port=82/tcp --permanent
firewall-cmd --reload
- 访问网页并且设置GitLab管理员密码
# 地址为http://IP:端口
http://192.168.66.100:82
# 设置完管理员密码后跳转到登录页面
# 用户名为root,密码为管理员密码