美文网首页
手把手教会在centos7搭建gitlab

手把手教会在centos7搭建gitlab

作者: 闲睡猫 | 来源:发表于2019-08-23 20:53 被阅读0次

虽然可托管代码的平台有很多选择,国外的有 github,国内的有 gitee 之类,但很多公司都会选择自建 gitlab 服务,觉得将代码托管在第三方,内心并不踏实

以下演示如何在 centos7 上搭建 gitlab

image

安装依赖包

# 安装依赖
$ yum install -y curl policycoreutils openssh-server openssh-clients policycoreutils-python
$ systemctl enable sshd 
$ systemctl start sshd

# 使用postfix发送邮件通知
$ yum install -y postfix 
$ systemctl enable postfix 
$ systemctl start postfix 

# 打开防火墙端口,如果需要
$ systemctl start firewalld
$ firewall-cmd --permanent --add-service=http 
$ systemctl reload firewalld

下载并安装gitlab

清华大学开源镜像站 获取最新的rpm包

# 下载安装包
$ wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.4.6-ce.0.el7.x86_64.rpm

# 安装gitlab
$ rpm -ivh gitlab-ce-11.4.6-ce.0.el7.x86_64.rpm

配置GitLab

$ sudo vim /etc/gitlab/gitlab.rb
# 指定访问的端口
# external_url 'http://127.0.0.1:9090'

# 重启gitlab
$ gitlab-ctl reconfigure

开放指定端口

指定的端口要加入防火墙,不然无法访问

# 启动防火墙
$ sudo systemctl start firewalld

# 查看防火墙
$ firewall-cmd --state

# 列出开放的端口
$ firewall-cmd --list-ports

# 将指定端口加入防火墙
$ firewall-cmd --zone=public --add-port=3306/tcp --permanent

# 重启防火墙
$ firewall-cmd --reload

此外,还需将端口加入安全组,各家云服务器的操作大同小异

访问gitlab

访问 http://127.0.0.1:9090/

首次访问需要初始化root密码,设置完成后,就能使用root登录

相关文章

网友评论

      本文标题:手把手教会在centos7搭建gitlab

      本文链接:https://www.haomeiwen.com/subject/wolxectx.html